Add multiroot-workspace variable scoping for `python.defaultInterpreterPath`
See original GitHub issueIt’s currently not possible to use multiroot-workspace variable scoping to configure python.defaultInterpreterPath, as @kimadeline mentioned in https://github.com/microsoft/vscode-python/issues/18207#issuecomment-1055840598.
My use case is the following. I have multiple python projects in my workspace but I want them all to use the same virtualenv, existing under one of the workspace folders. The tree structure looks like this:
/
├── python-a/
│ ├── .venv/
│ └── foo.py
├── python-b/
│ └── bar.py
To make it work with python.defaultInterpreterPath I need to configure it like this in the workspace file:
"python.defaultInterpreterPath": "${workspaceFolder}/../python-a/.venv/bin/python"
This is fragile, as it will break if python-b/ workspace folder changes its absolute path. With multiroot-workspace variable scoping it would be possible to express this dependency more robustly like this:
"python.defaultInterpreterPath": "${workspaceFolder:python-a}/.venv/bin/python"
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Settings Reference for Python - Visual Studio Code
Python settings reference. The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with....
Read more >Python Scope & the LEGB Rule: Resolving Names in Your Code
The concept of scope rules how variables and names are looked up in your code. It determines the visibility of a variable within...
Read more >How to correctly set PYTHONPATH for Visual Studio Code
I need to let VSCode use my own version of the environment variable $PYTHONPATH which would tell my regular python interpreter to import...
Read more >Python Variable Scope with Local & Non-local Examples
Learn about Python variable scopes and the 'LEGB' rule. Follow our step-by-step tutorial and see how global and nonlocal keywords are used today!...
Read more >Python Variable Scope (With Examples) - Programiz
In this tutorial, we'll learn about Python Global variables, Local variables, and Nonlocal variables with the help of examples.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi all, feature should be out in the pre-release version of the extension, use the following to try it out:
Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.
We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.