question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conda environments not detected

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
kennethjmyerscommented, Sep 16, 2019

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.

Removing /Users/${USER}/Library/Jupyter/kernels fixes the issue.

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:

  1. Update your conda, idk if this is essential but I haven’t been using mine in a while and I wanted to make sure I was on the most up to date.
  2. Do 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.
  3. Do conda activate into the environment you want to add
  4. Here are the crucial parts: Make sure ipykernel is installed with conda 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.
  5. You need install the kernel. If ipython kernel install doesn’t work try ipython 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 do ipython 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.
  6. conda deactivate and jupyter kernelspec list. You should hopefully start seeing the env names there. In my case this is

Available kernels: cs682 /Users/kenn/Library/Jupyter/kernels/cs682 py37 /Users/kenn/Library/Jupyter/kernels/py37 python3 /Users/kenn/Library/Jupyter/kernels/python3

  1. jupyter notebook on (base) and you should hopefully see the kernels as normal now image
2reactions
atg-abhishekcommented, Jul 1, 2020

conda install nb_conda_kernels fixed the problem quite easily since it auto-detects and picks up the existing conda envs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find conda environment - Stack Overflow
Names and Prefixes. For a Conda environment to have a name it must be installed in one of the envs_dirs directories (see conda...
Read more >
Conda environment not detected · Issue #11710 - GitHub
I've been using conda and jupyter lab/notebooks for years. I've been using VSCode for a few weeks while developing and deploying ...
Read more >
PyCharm - Configure a conda virtual environment - JetBrains
PyCharm supports creating virtual environments for Python with Conda. The following procedure applies to all supported operating systems.
Read more >
Managing environments - Conda
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them.
Read more >
Virtual Environments - Problem Solving with Python
To create the new virtual environment, open the Anaconda Prompt and issue the command: ... The conda create command builds the new virtual...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found