[Python] VS Code cannot automatically activate and switch to the selected virtual Python...

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    A few days ago, I reinstalled Windows 10, then re-downloaded VS Code and Miniconda3. When I select a virtual environment from the bottom bar in VS Code and run a Python file, the integrated terminal does not start in the selected virtual environment.

    Instead, the terminal runs the file using my system-wide Python interpreter, and only afterwards the following two commands appear automatically in the terminal:

    PS D:\snow\file\postGra> python -u "d:\snow\file\postGra\test.py"
    hello
    PS D:\snow\file\postGra> D:/snow/sw/miniconda3/Scripts/activate
    PS D:\snow\file\postGra> conda activate base


    Additionally, a separate cmd window briefly flashes during execution.

    What I have tried:


    • Changed the integrated terminal to both cmd.exe and PowerShell — no effect;


    • Reinstalled both VS Code and Miniconda3 — problem persists;


    • Screenshot of the terminal while running the code: https://i.sstatic.net/wjJRbmCY.jpg.
    My system:


    • OS: Windows 10 Home Edition;


    • Miniconda version: conda 25.5.1;


    • VS Code version: 1.102.2;


    • Electron: 35.6.0;


    • OS Build: Windows_NT x64 10.0.18363.

    I just want the integrated terminal to activate and use the selected virtual environment automatically when I run a Python file — as it used to before.

    Continue reading...

Compartilhe esta Página