Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 932
Alex Avatar asked Sep 17 '25 07:09

Alex


1 Answers

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.

like image 94
Sayandip Dutta Avatar answered Sep 19 '25 21:09

Sayandip Dutta