Search code examples
pythonvisual-studio-codeinterpreter

Python --version shows different version to VS Code


When i run python --version in the terminal of vs code, it outputs Python 3.8.8, even though my settings are

"workbench.colorTheme": "GitHub Dark Default",
"workbench.startupEditor": "none",
"window.zoomLevel": 1,
"python.defaultInterpreterPath": "/usr/local/bin/python3.11",
"python.autoComplete.extraPaths": []

and vs code 'Selected Python Interpreter' is 3.11.0 64-bit.

I want to know how to make it so the same python is running, as have been having issues with modules saying theyre not installed when they are etc. and modules not running etc.

Many python interpreters image I also seem to have a lot of python interpreters, and im not sure how to get rid of them


Solution

    • The Select Interpreters panel detects and displays all python versions available on the machine, including virtual environments. If you think you have too many environments, just uninstall the python version you don't want.

    • You use the python --version command in the terminal, the output result has nothing to do with the settings in your settings.json, it depends on the python settings in the environment variable path in your computer.

    • The role of "python.defaultInterpreterPath" in settings.json is:

      when you open a new workspace, if you do not manually select an interpreter, it will use this default interpreter as the python interpreter in the workspace.

    • You need to select the correct interpretation as the python interpreter in the Select Interpreters panel, and then use Run python File to execute the script

      enter image description here

    https://code.visualstudio.com/docs/python/environments#_working-with-python-interpreters