[Python] VSCode does not recognize venv

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    When I create a new project and the virtual environment using the venv python package, VSCode doesn't recognize the new virtual environment. I follow the bellow instruction:

    https://code.visualstudio.com/docs/python/environments

    The command that I use in the VSCode integrated terminal is:

    python -m venv .venv

    The terminal that I use is PowerShell 7, But I tried the CMD terminal too.

    After running this command, the .venv folder is created very well on the workspace and I checked its behavior on the terminal.

    I tried conda package manager to create a venv and VSCode recognizes it. The problem is only with the venv Python package.

    I also tried another Python version to create venv, But the problem still exists.

    I read this question:

    How can I set up a virtual environment for Python in Visual Studio Code?

    I know how to add an environment manually, but I expect VSCode to recognize my environments automatically.

    I added these lines to settings.json (Preferences):

    "python.venvPath": "~/.venv",
    "python.venvFolders": [
    "~/.venv/Scripts"
    ]


    I activated the venv manually using VSCode integrated terminal.

    The problem still isn't solved.

    This is a screenshot of my problem:

    [​IMG]

    I know how to add an environment manually, but I want it to be automatic.

    I tried VSCode on another PC, and it worked; It doesn't need anything to do except the presence of venv.

    VSCode Version: 1.58.0 Python Extension Version: v2021.6.944021595

    Continue reading...

Compartilhe esta Página