How to change interpreter in Visual Studio Code?

17,612

Solution 1

All you have to do is press ctrl+shift+p Then will get a search bar kinda thing on top of the screen.

Then type the following command:

> python: select interpreter

enter image description here

You will be provided with options. Select the one you want to use.

Solution 2

At the bottom of the MS Code screen is an info bar that lets you know what line, col, text encoding, etc... It also shows the python interpreter you are accessing.

If you click on the text for the version of python that is running, it will open a list of available interpreters on your system. If 2.7 is in your path, you can select it.

Solution 3

  1. Download and install the python version that you want https://www.python.org/downloads/

  2. Open the visual studio code

  3. Click on the Bottom left for the version

enter image description here

  1. Select the version that you want the code to be complied enter image description here
Share:
17,612
ban.85
Author by

ban.85

Embedded System rookie.

Updated on June 23, 2022

Comments

  • ban.85
    ban.85 almost 2 years

    I have installed on my system several Python interpreters, 2.x and 3.x versions. I am trying to prepare my work environment to allow easily switch between code written in both Python version. It is really important to have as much flexible setting in Visual Studio Code (VSC). The problem is that I have no idea how to set VSC terminal to run code in Python 2.x. Terminal output is needed because it allows to provide user input easily. I've tried instructions provided on VSC page, like manual interpreter's path indication in folder or workspace setting. I reinstalled Python 2.x to ensure PATH variable has been updated. When I run code with CodeRunner extension, it always run it in Python 3.x. Does anyone have similar issue and found how to change Python environment used by this integrated terminal?

    • ban.85
      ban.85 over 6 years
      Seems that it is needed to manually change the PATH variable. Re-installation of interpreter may not change it, even if user is sets this in installation setup. After manual PATH edition, terminals uses correct interpreter.
    • ban.85
      ban.85 over 6 years
      Also, when using workspaces and folders ensure that appropriate "python.exe" is indicated in respective settings.
  • Vincent
    Vincent almost 5 years
    I had this option but it was recently removed. Do you know how I can readd it?
  • maugch
    maugch over 4 years
    It won't change the interpreter used by the integrated terminal
  • maugch
    maugch over 4 years
    It won't change the interpreter used by the integrated terminal though.
  • Travis Heeter
    Travis Heeter about 2 years
    It looks like they removed this functionality. Now you have to do it via the Command Palette: Ctrl+Shift+P > Search for Interpreter > python:select interpreter