[IPython-dev] Notebooks enforce specific kernel

MinRK benjaminrk at gmail.com
Mon Jun 29 13:54:52 EDT 2015


I realize there's an issue with IPython's attempts to pseudo-activate a
virtualenv if one is found but IPython isn't using it. If the notebook
server is in an env and the kernel isn't, the kernel will try to activate
the server's env (right?). Should we:

1. remove the attempts to activate envs
2. pop VIRTUAL_ENV from the env passed down to kernels

(either or both)?

-MinRK

On Mon, Jun 29, 2015 at 10:41 AM, Thomas Kluyver <takowl at gmail.com> wrote:

> There's two ways you can use kernels with virtualenvs:
>
> 1. Don't install kernelspecs, launch the notebook inside virtualenvs when
> you want them.
> 2. Create kernelspecs referring to each virtualenv so you can switch
> between them in the notebook interface.
>
> Unfortunately, the two don't mix very well, so as you found, once you've
> installed a kernelspec it may end up using that instead of the virtualenv
> where you started the notebook.
>
> > 2: It seems notebooks contain a kernel specification of sorts. Does this
> mean I can't write a notebook that will run in both Python 2 and Python 3?
>
> If the user only has one Python kernelspec installed, that will be
> automatically selected whether the notebook specifies Python 3 or 2. If
> they have both, it will prefer the one it was saved with. However, there
> isn't currently any way to declare in the metadata that a notebook works
> with both, or with only one.
>
> Thomas
>
> On 29 June 2015 at 09:14, Steve Holden <steve at holdenweb.com> wrote:
>
>> Inevitably, almost as soon as I had sent the message I found and deleted
>> kernel specs in /usr/local/share/jupyter, which seems to solve the problem
>> (as well as explain the message about "attempting to work in a virtual
>> environment, as one of the specs was indeed pointing to en executable in a
>> virtualenv).
>>
>> regards
>>  Steve
>>
>> On Jun 29, 2015, at 5:04 PM, Steve Holden <steve at holdenweb.com> wrote:
>>
>> Since this may be a configuration issue I thought I'd ask on the list
>> before filing an issue.
>>
>> I created a Python2 virtual environment and installed IPython[notebook]
>> using pip, plus scipy and some other stuff. I then opened an existing
>> notebook, only to find on executing it that it claims scipy isn't installed.
>>
>> I noticed that the notebook had automatically opened with a Python 3
>> kernel, which I found very odd. sys.prefix tells me that it's running
>> Python 3 from a completely unconnected virtual environment.
>>
>> Now I did, once upon a time, attempt to install a Python2 kernel, but my
>> configuration control isn't good enough to remind me what I did. I can't
>> trace any reference to the "unconnected virtual environment" anywhere in my
>> ~/.ipython directory. This raises two questions:
>>
>> 1: Can anyone tell me where I may have installed this rogue kernel; and
>>
>> 2: It seems notebooks contain a kernel specification of sorts. Does this
>> mean I can't write a notebook that will run in both Python 2 and Python 3?
>>
>> regards
>>  Steve
>> --
>> Steve Holden steve at holdenweb.com / +1 571 484 6266 / +44 208 289 6308
>> / @holdenweb
>>
>>
>>
>>
>>
>>
>> --
>> Steve Holden steve at holdenweb.com / +1 571 484 6266 / +44 208 289 6308
>> / @holdenweb
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150629/2b57b0e1/attachment.html>


More information about the IPython-dev mailing list