How to Change the Python Version in Visual Studio Code

How do you get Visual Studio Code to use different Python interpreter?

Open command pallete with F1 (on Windows) and type Python: Select Interpreter.

VSCode change default python version

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.

python list vscode

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

  1. Check python version on terminal - python --version
  2. execute sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 << verfiy your paths correctly
  3. then run sudo update-alternatives --config python
  4. Select the python version
  5. 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

Path for Python



Related Topics



Leave a reply



Submit