Alex
Alex

Reputation: 44385

How to use a virtualenv from inside a jupyter notebook

I am using a jupyter notebook, and inside this running jupyter notebook I want to use a virtualenv.

I was able to create and source(?) a virtualenv by using these commands

!virtualenv venv
!. venv/bin/activate

but it looks like python is still being used from the standard location

!which python
/opt/conda/bin/python

Is there any way to create and switch virtual environments from inside a running jupyter notebook?

Upvotes: 4

Views: 1490

Answers (1)

Sayandip Dutta
Sayandip Dutta

Reputation: 15872

After activating the venv

pip install ipykernel
ipython kernel install --user --name=venv
jupyter notebook

In jupyter Notebook you would be able to choose between venv and python x.

Upvotes: 3

Related Questions