I have a monorepo structured like this:
myRepo/
├─ project_1/
│ ├─ .venv/
│ ├─ main.py
├─ project_2/
│ ├─ .venv/
│ ├─ main.py
├─ .gitignore
├─ README.md
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
Hard to figure out, took me a few hours so I'll leave this here for reference.
How to create separate virtual environments: microsoft/vscode-python "Mono Repo Set-up Guide"
TL;DR
myRepo)project_1, project_2)VS Code has a list of places, where it looks for virtual environments. Only environments located directly under the workspace are picked up automatically. You can also enter custom paths when running the Python: Select Interpreter command, though. Simply select "Enter interpreter path..." and navigate to your venv's /bin/python executable:




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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With