[Python] Visual Studio Code terminal doesn't activate Conda environment

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I read this Stack Overflow post on a similar issue, but the suggestions there don't seem to be working. I installed Visual Studio Code on my Windows machine and added the Python extension. Then I changed the Python path for my project to C:\Users\username\.conda\envs\tom\python.exe. The .vscode/settings.json has this in it:

    {
    "python.pythonPath": "C:\\Users\\username\\.conda\\envs\\tom\\python.exe"
    }


    The status bar in Visual Studio Code also shows:

    [​IMG]

    But when I do conda env list even after doing conda activate tom in the terminal I get the output:

    # conda environments:
    #
    base * C:\ProgramData\Anaconda3
    tom C:\Users\username\.conda\envs\tom


    Instead of:

    # conda environments:
    #
    base C:\ProgramData\Anaconda3
    tom * C:\Users\username\.conda\envs\tom


    Also the packages not installed in base don't get imported when I try python app.py. What should I do?

    where python runs, but it doesn't give any output.

    Also,

    import os
    import sys
    os.path.dirname(sys.executable)


    gives

    'C:\\Python38'

    Continue reading...

Compartilhe esta Página