nb_conda_kernels: Conda environments not detected
I’ve recently changed from miniconda3 and python 3.6 to anaconda3 and python 3.7. As a result, conda environments are not being detected and added as jupyter kernels.
I have nb_conda_kernels 2.1.1 installed in my base environment (python 3.7.0) and ipykernel 5.1.0 in my external environment (also python 3.7.0).
Within my external environment, I can see a kernel.json
file in ~\anaconda3\envs\env_name\share\jupyter\kernels\python3
and its content correctly points to the bin\python
directory of that environment.
However, jupyter kernelspec list
does not show the environment and it’s not available in either jupyter notebook or lab.
Update
I noticed that my jupyter_notebook_config.py
only had one entry for something else and nothing for nb_conda_kernels. I guessed that means jupyter is using the default KernelSpecManager.
So, I removed that file and restarted jupyter notebook. Kernels all detected and available!!
Even when I put the file back exactly as it was, I can create new environments and they are detected ok.
So - all is now working for me, but is there an issue installing nb_conda_kernels where a jupyter_notebook_config.py
file exists?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (3 by maintainers)
So I was having a similar issue, possibly the same as FBen3, I’m going to try to outline the steps I took to get my kernels showing up the way I want them to:
I wanted to make sure I was starting fresh with kernels so I decided to try this.
Well it didn’t fix my issues but it seemed to remove the kernels that looked like the ones in FBen3’s post.
Next step is to make sure you really follow the steps in this post especially for manually registering a kernel that already exists. I’ll try to outline the important ones:
conda install nb_conda_kernels
on the base environment, I believe this is supposed to auto detect new environments in the future but I actually haven’t tested it yet.conda activate
into the environment you want to addconda install notebook ipykernel
. I thought nb_conda_kernels should be picking up the new kernel but it was not so I had to do the next step.ipython kernel install
doesn’t work tryipython kernel install --user
, I believe the--user
flag is for if your kernelspec is located in /Users/… rather than /usr/… If you want a to add a specific name doipython kernel install --user --name [kernel_name] --display-name [kernel_name]
. IF YOU DON’T SPECIFY THE NAME, I THINK IT WILL OVERWRITE YOUR PYTHON3 KERNEL. I’m not a 100% sure on that but I think that’s why they don’t show up.conda deactivate
andjupyter kernelspec list
. You should hopefully start seeing the env names there. In my case this isjupyter notebook
on (base) and you should hopefully see the kernels as normal nowAs explain in the README, you can optionally install the virtual conda kernel specs in a place searched for by conda:
The kernelspec path needs to be writable by the users as kernelspecs will be dynamically updated by
nb_conda_kernels
.conda install nb_conda_kernels
fixed the problem quite easily since it auto-detects and picks up the existing conda envsokay, so I had a bunch of problems with this and it sucked up far too many hours of my life. Google ranked this thread up pretty high, so I’m posting it here for posterity. For anyone trying to do add conda-installed kernels in Docker, here is the process:
(
--display-name "Other Python"
in theipykernel
step if you want a different display name in the Jupyter dropdown, and you can avoid theCOPY
withconda create
changed toconda create --quiet --yes -n $conda_env python=3.6 pip ipython ipykernel
)@michaelaye a couple of things. First, where exactly is your
jupyter_notebook_config.py
file located, and what non-trivial content does it have in it? For instance, mine is in~/.jupyter/
; and I can see what’s active with this grep command:where exactly is your
jupyter_notebook_config.py
located; and what exactly does it have inside it (ignoring the comments)? For instance, I created one in~/.jupyter
,Second, you could try using the verbose enable/disable commands:
This should help us see what’s going on.
The error you’re seeing above is telling me that, somehow, your
jupyter_notebook_config.py
file already has some sort of setting in it that is overriding whatnb_conda_kernels
is trying to achieve locally.