Search code examples
pythonkerneljupyter-notebookvirtualenvjupyter

Juptyer not loading modules from Virtual Environment


I'm using a shell to create a virtual environment. I download virtualenv-15.1.0.tar.gz from https://pypi.org/packages/source/v/virtualenv/. I also install all required modules in the corresponding environment, including jupyter, ipython, and ipykernel.

I've also created a kernel for it

exec "$(ipython kernel install --user --name=my_virtual_env)

When I launch Jupyter, I can see the kernel and connect to it. However, when I try to import from one of the sources in my virtual environment, it doesn't recognize the module. Why doesn't it access the resources of my virtual environment when running jupyter?


Solution

  • The answer was that it wasn't enough to run Jupyter with the virtual env kernel, I had to activate the virtual env first using activate [virtual env name]