Creating Jupyter kernels
To have a conda
environment show as a kernel in Jupyter, two more steps are needed. The conda environment must be activated when these steps are run.
Install the ipykernel package¶
In order to use an environment in Jupyter, we need to
install the ipykernel
package in the environment:
conda install ipykernel
Create the kernel definition¶
The ipykernel python module includes a utility for adding a kernel definition. With the conda environment active, run the following command:
python -m ipykernel install --user --name my_kernel --display-name kernel_name
"my_kernel" and "display_name" can be any value you like, but each kernel you create should have a distinct name.
Modifying kernels¶
Do not execute !pip install
lines in your notebook.. This will install packages outside of the conda environment and potentially break other kernels.
To add packages to a kernel that is based on a conda environment, you must activate the environment on the command line and run conda install
or pip install
in the active environment.
Troubleshooting Kernels¶
If you kernel doesn't display, or won't launch, check the Jupyter output log.
In Open on Demand, each session has a card with a link to the Session ID.
Click on that link and open the output.log
file. That log file will often provide clues as to why kernels cannot launch.