Conda and Jupyter

There is one non-obvious caveat to using Conda environments: it is easy to run Jupyter in the wrong environment so that it won't see the packages you have installed, or the version of Python will differ. In fact, while you can run Jupyter from a specific environment, this method is not recommended: as Jupyter moved from a Python-specific workflow to the concept of an abstract notebook-kernel protocol, it is recommended you execute it from the base operating system, giving it access to all environments and kernels at once. 

There are two ways to register a specific environment in Jupyter. First, you can use the dedicated registration command of ipykernel from the environment:

conda activate myenv
python -m ipykernel install --user --name myenv --display-name "my new environment"

Another way (it is just a semi-automated wrap around the preceding method, but is better in our opinion) is to install the nb_conda package in your root environment:

conda deactivate
conda install nb_conda

This package, developed and supported by Anaconda, will scan all the Conda environments available, and register all of them with Jupyter. Now, you can run Jupyter from the root environment. Within the Jupyter launcher, you'll see new buttons for Python in each new environment. You will be able to switch kernels (environments) from within each notebook as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset