4

I want to specify the Python path in tasks.json without an explicit full path. I used to do this using python.pythonPath, but that setting is now deprecated. What is the alternative way to retrieve the currently selected Python path? Are there any other VS Code environment variables?

1
  • 1
    seems like python.venvPath / python.defaultInterpreterPath, look Commented Aug 31, 2021 at 6:02

3 Answers 3

1

For the current python path, you need to select an interpreter and the currently used one is shown as a relative path in the box.

Current Python Path

In tasks, have args called options so you can define env and PYTHONPATH there

args call

You can find more details about tasks from the Tasks in Visual Studio Code documentation.

Sign up to request clarification or add additional context in comments.

Comments

0

If you have the Python VSCode extension installed, and an interpreter is selected, then you can get the path to that interpreter in tasks.json using ${command:python.interpreterPath}.

Comments

-2

You can open VS Code command selector with ctrl + shift + p and type "Python: Select Interpreter" to open a dropdown menu of all available interpreters. Doing this should create the appropriate entry to settings.json (which was python.pythonPath for me with version Python plugin version v2021.8.1159798656)

You can also change the interpreter from the bottom toolbar.

1 Comment

This doesn't answer the question, OP needs a variable that can be used in the tasks.json file (or any other, I guess) that holds the path of the currently selected interpreter through that toolbar. python.pythonPath does not hold that value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.