My Digital Garden

Setting up virtual python kernel in environment


Do this to enable code to run inside Jupyer notebooks in your new environment.


Once you have created and activated a conda environment:

Let's assume environment is called learn, and we are in the Anaconda Prompt under Windows or at a shell prom,pt in WSL2/Linux:

  • create and activate environment conda create --name learn conda activate learn

  • install ipykernel and notebook : conda install ipykernel notebook

  • match the kernel to the name of the environment: python -m ipykernel install --user --name=learn

Use inside Jupyter Notebook:

  • run Jupyter Notebook jupyter notebook

  • access the environment when creating a new notebook:

Use inside Jupyter Lab

  • run Jupyter lab jupyter lab

  • access the environment when creating a new notebook:

  • or access this environment for an existing notebook

Use inside VS Code

Kernels / environments set up this way are also accessible inside VS Code via the kernel selector when running python scripts:

or Jupyter notebooks:

See also