Skip to content

Vscode doesn't know which Python virtualenv to use if there there are multiple python projects opened #25134

Description

@elieobeid7

I'm using Windows 11 latest update, Vscode latest version, Python version 3.13.3, I'm using pip and vrtualenv, not uv. I don't use uv. I have ruff extension and pylance extensions for Python installed.

To reproduce this bug

  1. Create a python project A, with virtualenv and install some dependencies, and set VScode to use the virtualenv you created by changing the Python interpreter in Vscode.

  2. Create a python project B, with virtualenv and install some different dependencies, and set VScode to use the virtualenv you created by changing the Python interpreter in Vscode.

  3. close all Vscode instances

  4. Open now project A in VSCode, everything works fine

  5. Keep project A open, create a new vsode window, ctrl + shift + n then open project B

Now you'll notice Vscode complaining about some pip dependencies missing from project B, that's simply because vscode is still connected to project A virtualenv, you'll have to switch the interpreter for project B manually by selecting the correct virtualenv.

Activity

  1. eleanorjboyd commented on Dec 12, 2025

    @eleanorjboyd
    Member

    Hi there! 👋

    Thanks again for reporting this issue. Based on what you described, this appears to touch the same parts of our environment/activation logic that we’ve recently replaced in our new Python Environments extension. A lot of the behavior in this area now follows a completely different activation and environment-resolution path, so this may already be fixed.

    We’d really appreciate it if you could try the new extension and let us know—this helps us confirm that the new implementation addresses older issues like yours.

    👉 Enable the new extension with "python.useEnvironmentsExtension": true (then you should see a Python icon in the sidebar.
    📫 More details on enablement here
    📝 Useful background documentation on activation here

    If you do run into issues, please include as much info and reproduction steps or the "Report issue..." command inside VS Code!

    Thanks again for reporting this originally, and for helping us validate the new environment direction for Python in VS Code 🙌

  2. elieobeid7 commented on Dec 13, 2025

    @elieobeid7
    Author

    Eleanor Boyd (@eleanorjboyd) Thank you for your reply.

    "python.useEnvironmentsExtension": true breaks pylance completely

    Steps to reproduce

    1. Have a virtualenv created via the CLI as you normally create virtualenvs and install some dependencies in via pip
    2. Now tell VSCode to use the environment, all works well so far
    3. now go to settings, add "python.useEnvironmentsExtension": true and restart vscode
    4. You'll see many errors such as
    Image

    Also VSCode will complain about every library you installed in the virtualenv, if you installed numpy for example and you try to import it, it will say not found. Pylance is completely broken.

    Remove "python.useEnvironmentsExtension": true from the settings and restart VSCode, everything goes back to normal.

    "python.useEnvironmentsExtension": true is literally unusable at this stage. I don't know how it was written and what kind of testing it went through. Didn't anyone try to use it with Pylance before shipping to production? Or does it work exclusively with uv and hasn't been tested with the traditional virtualenv and pip? I have no idea.

  3. nwheatleKite commented on Feb 5, 2026

    @nwheatleKite

    I have the same issue - on a mac. I have a folder workspace project with multiple subfolders each with their own virtual environment and dependencies. When I click to 'Select Interpreter' - my venvs are not listed. When I select to 'Find interpreter' and navigate to only of my venv /bin/python - nothing happens.

    WORKAROUND that helped me was creating a [my-root-project].code-workspace file that tells vscode to treat your list of folders as if they were root folders. The trick is to then find this .code-workspace file in your file explorer and click on that to open up a new VSCode. This allowed vscode to understand which venv's had which dependencies and enabled me to move one. However - it would have saved me a lot of time I needed today if I could just select my interpreter.

    {
        "folders": [
            {
                "name": "BLAST",
                "path": "services/blast"
            },
            {
                "name": "CODON-TRANSFORMER",
                "path": "services/codon-transformer"
            },
            {
                "name": "ROOT",
                "path": "."
            }
        ],
        "settings": {
            "python.terminal.activateEnvironment": true
        }
    }
    
  4. elieobeid7 commented on Mar 1, 2026

    @elieobeid7
    Author

    nwheatleKite thank you, this works but you first have to open the project as a separate for venv to work correctly, if you start a new project with new venv inside a workspace, it will still not be detected correctly.

    So you have to open it in a new folder, make sure that venv works, then open it again in the workspace.

  5. eleanorjboyd commented on Sep 23, 2026

    @eleanorjboyd
    Member

    🤖 Thanks for the additional context. Environment selection now uses the Python Environments extension by default, but the original two-window problem has not yet been confirmed on that current path. Could you retry the original project A/project B steps on the latest Python and Python Environments extensions and attach the output from Python: Report Issue, including the Python and Python Environments output-channel logs from project B after it opens with the wrong interpreter? Issues marked info-needed are automatically closed after 30 days without a reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions