Vscode Change Default Python Version
Solution 1:
In VSCode's command palette choose the option
Python: Select Interpreter
And choose the interpreter you want to use. This will automatically add the setting correctly to your settings.json
file in your .vscode
folder for your workspace.
This will take care of Python management in VSCode.
Now coming to setting the right python to be used by your os/terminal when trying to run scripts.
Since you are using linux, make sure your python is the right version thats linked
- Check python version on terminal -
python --version
- execute
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
<< verfiy your paths correctly - then run
sudo update-alternatives --config python
- Select the python version
- Try
python --version
again and check
If on Windows make sure path to Python 3.8.x is set at a higher priority in your Path Environment Variable. Py3 should be above your other paths
Solution 2:
Open settings and search for Python Default Interpreter Path
.
In your case, you wish to set it to /usr/bin/python3.6
. Though I would suggest using a virtual environment.
{"python.defaultInterpreterPath":"/usr/bin/python3.6"}
If you are using virtual environment, to ensure that the terminal is using the associated python environment, check the second option Python > Terminal: Activate Environment
:
In settings.json
it is called "python.terminal.activateEnvironment": true
.
One reason your change did not persist, was because in your screenshot, you opened your workspace'ssettings.json
.
To make it default, you should edit your user'ssettings.json
instead.
This you can access with Ctrl+Shift+P
, Preferences: Open Settings (JSON)
.
Detailed instructions can be found in the documentation "Manually specify an interpreter", including using environment variables as the interpreter's path.
Also, "python.pythonPath"
has been deprecated:
2021.6.0 (16 June 2021) 5. Added python.defaultInterpreterPath setting at workspace level when in pythonDeprecatePythonPath experiment. (#16485) 8. Show python.pythonPath deprecation prompt when in pythonDeprecatePythonPath experiment. (#16485)
2020.7.0 (16 July 2020) 9. Prompt users that we have deleted pythonPath from their workspace settings when in Deprecate PythonPath experiment. (#12533)
2020.5.0 (12 May 2020) 6. Do a one-off transfer of existing values for python.pythonPath setting to new Interpreter storage if in DeprecatePythonPath experiment. (#11052) 8. Added prompt asking users to delete python.pythonPath key from their workspace settings when in Deprecate PythonPath experiment. (#11108) 12. Rename string ${config:python.pythonPath} which is used in launch.json to refer to interpreter path set in settings, to ${config:python.interpreterPath}. (#11446)
2020.4.0 (20 April 2020) 13. Added a user setting python.defaultInterpreterPath to set up the default interpreter path when in Deprecate PythonPath experiment. (#11021)
Post a Comment for "Vscode Change Default Python Version"