5

I created a virtual environment and installed ipython[all] and jupyter with pip. When I run jupyter lab, open a notebook, and try importing a package I installed inside the virtual environment, I get “ModuleNotFoundError.”

Running ipython in the console and importing works. Also, which jupyter does point me to the right executable in the virtual environment.

3 Answers 3

5

The issue comes from the fact that your environment is not registered in the kernelspec. You can activate your venv, run

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

and then select the kernel some_nice_name for your notebook (you can use the kernel even if you run jupyter lab from another venv ; keep in mind that the python running jupyter lab and the kernel are in general different)

Sign up to request clarification or add additional context in comments.

Comments

-1

In addition to installing jupyter, I need to install jupyter lab. Otherwise, even the virtual environment jupyter executable actually silently falls back to the system Jupyter Lab installation.

Comments

-1

install jupyter lab in the virtual env:

pip install jupyterlab

1 Comment

This is actually a bad idea. If you have 5 virtual environments, you would install jupyter lab in each one? The purpose for jupyter is having an interactive environment to execute code. Each virtual environment will be dedicated for a specific purpose (image processting, NLP, deep learning, etc)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.