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?
3 Answers
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.
In tasks, have args called options so you can define env and PYTHONPATH there
You can find more details about tasks from the Tasks in Visual Studio Code documentation.
Comments
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
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.

python.venvPath/python.defaultInterpreterPath, look