Repository navigation
Cannot use virtual environment outside workspace in VSCode notebooks #25175
Description
This is a bug I cannot wrap my head around, Visual Studio Code does not let me choose a virtual environment outside my workspace when using notebooks. I should first mention that everything works perfectly on PyCharm notebook Professional Edition (but I prefer VSCode's way of using notebooks) so it's not a problem from my computer.
When I click on Select Kernel (top right of the notebook screen), I only see my two base Python environments. Both work. I would however like to use one of my virtual environment. So I used the >Python: Select Interpreter option because in the Select Kernel, it does not let me enter a custom path:
Here, it's easy for me to find the path/to/python.exe of my virtual environment (I'm on Python 3.12.5) by clicking on Enter interpreter path:
However, when I click and locate path/to/python.exe, nothing happens.
There is still, in the notebook, the Select Kernel button saying that I have not selected any Python environment for my notebook. And when I click on it, my virtual environment that I previously selected does not appear. Only my base Python versions appear.
Things I did:
- I restarted my computer.
- I uninstalled VSCode, and reinstalled VSCode.
- I looked for Windows Updates.
- I looked for VSCode Updates. None were found.
- I installed
ipykernelto my virtual environment but it was already installed. - I made sure I had the
Pythonextension enabled on VSCode. - I made sure I had the
jupyterextension enabled on VSCode. - I made sure the base environments worked as expected when choosing them in
Select Kernel. They did. - I made sure everything worked with my virtual environments in PyCharm Professional. They did.
- I used
python3 -m ipykernel install --user --name=projectnameafter activating my venv. - I tried to do
>Jupyter: create interactive Windowso that kernel will connect to the Python environment automatically and then try to see if clicking onSelect Kernelwould make the venv appear. It doesn't work. It appears in my interactive window, but not in my notebook. - I tried to clear the cache:

Does this issue occur when all extensions are disabled?:
No because I need the Jupyter extension and the Python extension. If I don't have those extensions enabled, another issue happens: I can't use notebooks at all but that's a normal issue.
Version: 1.98.0 (user setup)
Commit: 6609ac3d66f4eade5cf376d1cb76f13985724bcb
Date: 2025-03-04T21:06:18.612Z
Electron: 34.2.0
ElectronBuildId: 11044223
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.22631
Steps to Reproduce:
- Make a venv (do not use
conda) outside your workspace. - Try to use it in a notebook.



Activity
[-]Cannot use virtual environment outside workspace for notebooks[/-][+]Cannot use virtual environment outside workspace in VSCode notebooks[/+]JasonMendoza2008 commentedon Mar 9, 2025
Corresponding SO: https://stackoverflow.com/q/79463940/11092636
DonJayamanne commentedon Mar 28, 2025
Please could you enable logging as follows:
Jupyter->LoggingtraceJupyteroutput panel (use the commandJupyter: Show Outputto get to the logs).JasonMendoza2008 commentedon Mar 29, 2025
Here are the logs:
JasonMendoza2008 commentedon Mar 29, 2025
And to give more information, using VSCode with "normal" .py files works perfectly well with those same virtual environments:
DonJayamanne commentedon Mar 29, 2025
Please can you take a screenshot of the python environments after you check ‘Select kernel-> Python env’
Based on the logs, it should show up
Please do share the logs after you’ve taken a screenshot as well
Oh yes, the kernel picker doesn’t let you enter paths to the python env, as that’s a feature explicitly provided by the python extension, hence you’d need to use the approach you’ve mentioned
JasonMendoza2008 commentedon Mar 29, 2025
They actually appear for half a millisecond, cf. video (you have to go frame by frame to see it, it's very fast)
2025-03-29.16-19-35.mp4
Logs:
The last two lines are probably the problem?
JasonMendoza2008 commentedon Mar 29, 2025
This is the first time I noticed that they appear for half a second actually, sorry for not mentioning it earlier but as you can see in the video it's very fast.
Th3RandyMan commentedon Jun 9, 2025
I'm having the same issue, but my venv appears for nearly a second. I've been trying to select it before it disappeared, but I don't think I'm fast enough.
Th3RandyMan commentedon Jun 9, 2025
I was able to fix the issue by changing the path to the environment file and reloading the window. Listed as "Python: Env File" in the settings.
DonJayamanne commentedon Jun 13, 2025
Karthik Nadig (@karthiknadig)
Based on the logs the last entry in Jupyter extension is as follows
First line is the message from the Python extnsion API (via events)
I.e. Python extension is sending a message about removing the environments.
As a result Jupyter extension doesn't display them, after all, there's no such env from Jupyter ext perspective.
DonJayamanne commentedon Jun 13, 2025
JasonMendoza2008
I'm sorry for never getting back to you on this issue, somehow this slipped through the cracks.
I've had a look and identified the problem, for some reason the env is marked as removed by the Python extension API.
Hence transferring to this repo.
Once again apologies for the delay.
JasonMendoza2008 commentedon Jun 14, 2025
Don Jayamanne (@DonJayamanne) Thanks, no worries. Thank you for transferring.
eleanorjboyd commentedon Dec 8, 2025
Hello! We are now rolling out a new extension, the Python Environments extension, which we built to improve all environment related items for Python. Could you give this new extension a try and see if it fixes the issue for you? Info on how to enable it can be found here: microsoft/vscode-python-environments#581. Thanks!
github-actions commentedon Jan 8, 2026
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Happy Coding!
DmtkD commentedon Sep 23, 2026
Hello, Eleanor Boyd (@eleanorjboyd), Don Jayamanne (@DonJayamanne)
I have occurred with this issue.
The behavior is the same like in description
Here is my setup
Extension version via command
code --list-extensions --show-versionsWorkaround:
Disable to use Python Environments Extension in setting:
python.useEnvironmentsExtensionDmtkD commentedon Sep 23, 2026
Is it possible to reopen this issue, or would it be better to open a new one?