Skip to main content

Adding a virtual environment in Jupyter notebook

First, activate your virtual environment (shell) and run this:

pip install --user ipykernel

We need to manually add the kernel if we want to have the virtual environment in the Jupyter Notebook. That is why we need to add it by running this code.

python -m ipykernel install --user --name=myenv

 

image.png

when creating a new notebook, you can choose your new kernel image

 

If you have finished with the virtual environment and did not need it anymore, you could remove it using this code.

jupyter kernelspec uninstall myenv