How to make virtual environments get recognized per project? #24950
-
I have the following structure when using # tree -C -L 2 "C:\venvs\"
C:\venvs\
├── geomag
│ ├── Include
│ ├── Lib
│ ├── Scripts
│ ├── pyvenv.cfg
│ └── share
├── myven
│ ├── Include
│ ├── Lib
│ ├── Scripts
│ └── pyvenv.cfg
... How can I make these automatically recognized when opening editor for a file in a different project ditrectory? For example: Editing a file in # cd C:\mydev\geomag
# activate
# ls
Directory: C:\mydev\geomag
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2025-03-28 10:45 venv
-a--- 2025-03-28 12:18 7200 geo.py
...
# tree -C -L 2 .\venv\
.\venv\
├── Scripts
│ ├── Activate.ps1
│ ├── activate
│ └── activate.bat
├── venvlink-autoenv.leave.ps1
└── venvlink-autoenv.ps1
# python.exe .\geo.py
However, editing the file the venv installed packages are not recognized. How can I make VScode automatically recognize the venv used for the current project directory? PS. I'm using Windows. And please up-vote for this: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Have you tried this:
That should automatically select the environment. |
Beta Was this translation helpful? Give feedback.
Have you tried this:
.venv/Scripts/activate
code .
from that terminal (code-insiders .
for insiders version of VS Code)That should automatically select the environment.