Skip to content

Cannot use virtual environment outside workspace in VSCode notebooks #25175

@JasonMendoza2008

Description

@JasonMendoza2008

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:
enter image description here

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:
enter image description here

However, when I click and locate path/to/python.exe, nothing happens.
enter image description here

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 ipykernel to my virtual environment but it was already installed.
  • I made sure I had the Python extension enabled on VSCode.
  • I made sure I had the jupyter extension 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=projectname after activating my venv.
  • I tried to do >Jupyter: create interactive Window so that kernel will connect to the Python environment automatically and then try to see if clicking on Select Kernel would 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:
    Image

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:

  1. Make a venv (do not use conda) outside your workspace.
  2. Try to use it in a notebook.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions