Adding a virtual environment to a Jupyter notebook.

jupyter python

This is the Python newbie section. So I had a working virtualenv going, and I could import with a .py file, but put all of that in a Jupyter notebook and suddenly nothing could be found.

Ok, so you have to use a kernel with the environment of your virtualenv, which I learned from a much longer and better blog post than what is here. Mercy sakes, this environment stuff in Python is maddening.

So pip install --user ipykernel to get set up, and

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

where myenv is the name of the virtualenv. Then in the Jupyter notebook, Kernel->Change kernel->(select the name of your environment).

© Amy Tabb 2018 - 2023. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.