I’m confused (noob) about the relationship between IPython kernels and Python virtual environments (at least as they are used in JupyterLab).
For example, if I activate a virtual environment (in my case typically with
workon my_venv) and then
python -m ipykernel install --user --name my_kernel --display-name "Python (my_kernel)"
what is the connection between the kernel
my_kernel and the virtual environment
In my typical workflow, once both the virtual environment and the kernel are set up I
$ workon my_venv $ [my_venv] jupyter lab
and end and end up in a Juyter session where
- the terminal acts as if the
my_venvhas been activated;
- all shell commands issued from any notebook, regardless of associated kernel, act as if
my_venvhas been activated; and
- a notebook has access (only) to packages — e.g., via
import— installed in the associated kernel running (which need not be
Also, in addition to any kernels I have explcitly defined, I have a (local to
my_venv?) kernel called “Python 3 (ipykernel)” which is associated with
So my questions are:
- is the above a reasonable summary of the relationship between IPython kernels and Python virtual environments? Am I missing something important?
- Is it correct that I don’t really ever need to create my own kernel manually for a virtual environment, since one is created automatically, and is exactly the same as the manual one that’s created with the step above (except for name and visibility)?
- Is there a way to name the automatically created kernel, and is there a way to customize that step (when and with what tools, e.g., to change its name).