Add a Conda Environment to Jupyter Kernel – Jupyter Notebook Tutorial

By | April 27, 2023

We can use conda create command to create a virtual python environment easily. However, how to add this environment to jupyter notebook? In this tutorial, we will tell you how to do.

Preliminary

To create an environment using conda, you can read:

Install and Use Both Python 2 and Python 3 in Windows with Anaconda – Python Tutorial

To show all environments in you sysmte, you can read:

List All Created Virtual Environments in Conda – Anaconda Tutorial

How to add conda environment to jupyter kernel?

As to us, we have created these environments.

show all environments using conda env list

However, py37_yzl  does not exist in jupyter notebook kernel list.

Adding a Conda Environment to Jupyter Kernel

In order to add py37_yzl we can do as follows.

Step 1: activate py37_yzl

conda activate py37_yzl

Step 2: install ipykernel

python -m pip install ipykernel

If you have installed ipykernel, you can skip this step.

Step 3: add py37_yzl to jupyter notebook kernel list

python -m ipykernel install --user --name py37_yzl

Then, we will see:

install kernel in jupyter notebook

Finally, you can see py37_yzl in jupyter notebook kernel list.

Steps to Adding a Conda Environment to Jupyter Kernel