Description
Greetings. I'm currently in a Jupyter kernel hell. I can't figure how to fix it. And I'm not sure whether it's a Jupyter or conda issue, so thanks for the patience!
Here's my setup. I use conda to manage my python environments. I work on many different projects that use Jupyter notebooks, each project having its own environment (specified in environment.yml
files).
I recently reinstalled conda to update my root environment to Python 3.6 and conda 4.3.13. As part of this reinstallation, I tried to remove files that I thought would get freshly regenerated including jupyter configuration files (IIRC).
This reinstallation of conda triggered the issue:
- when I run
jupyter notebook
with the conda environment activated, the specific conda environment is not available in the spawned notebook browser. - If I run
python -m ipykernel.kernelspec
(I think) then I the activated conda environment becomes the defaultPython 3
kernel for all my notebook servers. - Creating new conda environments with
jupyter
installed does not add them to the list of kernels in jupyter.
Before I reinstalled conda (and deleted jupyter config directories since I wanted to freshly reinstall everything related to python):
- if I launched a notebook from an activated conda environment, the default
Python 3
kernel would correspond to that notebook - if I created a new conda environment, the kernel would show up as a choice in all jupyter sessions regardless of which environment
jupyter notebook
was running from - I never had to mess around with configuration files.
So I think I've broken something and I want the old (or any environment aware) behavior back. Tagging @minrk @jakevdp @kalefranz @asmeurer in case you or someone you mention can help. Will really appreciate any guidance!
Activity
jkingphd commentedon Mar 14, 2017
For what it's worth, I am experiencing the similar issues. I am on Windows 10, and I completely removed Anaconda using the recommended steps (anaconda-clean, then uninstall from add/remove programs). I installed the Python 3.6 version of Anaconda, and now my Jupyter Notebook is completely borked. I can launch the server, but I can't access any of my conda environments (old or new). Only one kernel is listed: "Python 3." If I install Jupyter from within the environment and launch the notebook server while the environment is activated, sys.path still refers to the base installation path. Is something broken with respect to 3.6?
takluyver commentedon Mar 14, 2017
I think Continuum stopped shipping their environments-as-kernels plugin by default - you can probably still install it, or you can set up kernels for environments manually. We're thinking about better ways to expose environments to Jupyter.
jkingphd commentedon Mar 14, 2017
Thanks for the quick reply, this restored my workflow entirely. I think you are right about Continuum. I guess it serves me right for relying on pre-built distros, heh.
dhimmel commentedon Mar 16, 2017
@takluyver, thanks for that info! It was enough for me to track down
nb_conda_kernels
(anaconda cloud, repo). Once I'm back at the affected machine, I'll let you know if this fixes my issues.nb_conda
also looks interesting (allows you to manage conda environments in a Jupyter browser tab).In worst case, I should be able to use the single kernel installation commands you link to:
But I'm not a huge fan of this solution as it's a manual step. Furthermore, when we have several people collaborating on a repo, we want them to all have the same kernel names for conda environments.
dhimmel commentedon Mar 16, 2017
conda install nb_conda_kernels
failed with:So I installed
nb_conda_kernels
from conda-forge using:Now I can choose from my conda environments in the Jupyter kernel menu. Phew!
Note that the
nb_conda_kernels
README states:dhimmel commentedon Mar 16, 2017
@takluyver or other repo members: close this issue at will. I may still report some additional findings here...
takluyver commentedon Mar 16, 2017
Thanks
xiaotangfeidao commentedon Apr 29, 2017
I had similar issue, this was really helpful. Thanks
tsu-nera commentedon May 1, 2017
Thank you. I had same problem.
bede commentedon Jul 12, 2017
Such a useful thread. IMO it is more than a little counterintuitive that notebooks do not use the active conda env by default, nor that they are even visible!
JyiHUO commentedon Aug 1, 2017
Thank you, this is very helpful for me. I am sucking in this problem about two day
NumesSanguis commentedon Aug 29, 2017
I did the following:
So then I tried:
Then in a Jupyter notebook:
Still not referring to the right kernel... This is quite an annoying change that terminal kernel and Notebook terminal are not the same.
This is what I tried (based on: https://github.com/Anaconda-Platform/nb_conda_kernels/blob/fe861722902df9c97f47bbf6e16c8c634d17144f/README.md):
But I got an error that I don't have the
requirement.txt
(sorry lost actual error). So I reinstalled everything and did the following (which finally worked):I might be a beginner, but I don't understand what the purpose is of creating an environment and installing all packages there, if in the end the notebook doesn't use this kernel with what you've just installed.
20 remaining items