Home > Enterprise >  Can I have multiple subfolders with virtual python environments in VS Code?
Can I have multiple subfolders with virtual python environments in VS Code?

Time:10-26

I have a monorepo structured like this:

myRepo/
├─ project_1/
│  ├─ .venv/
│  ├─ main.py
├─ project_2/
│  ├─ .venv/
│  ├─ main.py
├─ .gitignore
├─ README.md
  • Can VS Code handle multiple python venvs in subfolders?

After some googling I managed a find one solution, but its not very elegant. I created a workspace and added the folders /project_1 and /project_2, that worked and I can easily switch and select Python Interpreter. I also need to modify files in /root from time to time so I added this folder as well. All this makes the Explorer folder structure bigger and more cluttered with duplicates of itself:

workspace/
├── myRepo/
│   ├── project_1/
│   │   ├── .venv/
│   │   └── main.py
│   ├── project_2/
│   │   ├── .venv/
│   │   └── main.py
│   ├── .gitignore
│   ├── README.md
│   └── myRepo/
├── project_1/
│   ├── .venv/
│   └── main.py
└── project_2/
    ├── .venv/
    └── main.py

CodePudding user response:

VS Code has a select interpreter

enter interpreter path

find

python binary

Once you have used a cutom interpreter path, it is known to VS code and will be directly selectable using the Python: Select Interpreter command.

  • Related