In VSCode, how can I get the path of currently selected Python?

Viewed 406

python.pythonPath setting is deprecated. What is an alternative way to retrieve currently selected Python path? Any VSCode environment variables? I want to specify python path in task.json without explicit full path.

2 Answers

For the Current python path 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 more details about tasks this documents Tasks in Visual Studio Code

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.

Related