question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add multiroot-workspace variable scoping for `python.defaultInterpreterPath`

See original GitHub issue

It’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:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
karrtikrcommented, May 24, 2022

Hi all, feature should be out in the pre-release version of the extension, use the following to try it out:

image

3reactions
brettcannoncommented, May 12, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found