3

I've set up different Python venv/virtualenv environments on my Debian 12, each with their own packages.

However, I want to use/install Jupyter Notebook only once (in just one virtual environment).

When I start the venv/virtualenv environment Jupyter Notebook, how can I make it use installed packages from the other virtual environments as well?

1 Answer 1

3

To run Jupyter from one virtual environment while using packages from another, follow these steps

1. Activate the selected venv/virtualenv environment

source /PATH/TESTVENV/bin/activate

2. Install ipykernel in the selected venv/virtualenv environment

pip install ipykernel

3. Register the Jupyter kernel

python -m ipykernel install --user --name=TESTVENV --display-name "My Test environment"

4. Leave the selected venv/virtualenv

deactivate

5. Start your venv/virtualenv environment where Jupyter Notebook is installed

source /PATH/JUPYTER/bin/activate

jupyter notebook

6. In the notebook select

Kernel > Change kernel > "My Test environment"

or

Menu > File > New > Notebook > Select Kernel > "My Test environment"

Now Jupyter is running from venv JUPYTER, but the code uses the packages from venv TESTVENV.

More Sources:

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.