Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use python virtual environments in VS Code jupyter notebooks integration?

I have created a virtual environment with venv as follows from VS Code integrated terminal:

python3 -m venv <name>

after cd in the directory, I activated it by doing source <name>/bin/activate

How can I make it available for the kernel of my VS Code integration of jupyter notebook? I only see the default python installations as possible kernels i.e. usr/bin/python3

Also, let's say I would like to then revert the process and remove that kernel - how can I do it?

like image 823
G. Macia Avatar asked Dec 19 '25 16:12

G. Macia


2 Answers

As mentioned by Molly Wang below, the kernel does not appear in the list of Python environments and you should upvote this issue in Github. As a workaround, you could open the python interpreter menu in VS Code (crtl+p) and type "Python interpreter" and then navigate to your venv python (choose the right version within the /bin folder in your venv)

enter image description here

like image 122
G. Macia Avatar answered Dec 21 '25 06:12

G. Macia


Create a new python environment via the console, then from a notebook try and select it as a kernel it doesn't appear in the list of python environments. This phenomenon also occurs in my VS Code.

There's an issue in github, Python extension team will see if there's enough upvotes, then they will consider this feature request in future planning. You may upvote the issue.

like image 29
Molly Wang-MSFT Avatar answered Dec 21 '25 05:12

Molly Wang-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!