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?
- 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.852017-12-01 22:17:55 +00:00Commented Dec 1, 2017 at 22:17
- Also, when using workspaces and folders ensure that appropriate "python.exe" is indicated in respective settings.ban.85– ban.852017-12-02 09:00:28 +00:00Commented Dec 2, 2017 at 9:00
4 Answers
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.
1 Comment
Download and install the python version that you want https://www.python.org/downloads/
Open the visual studio code
Click on the Bottom left for the version
3 Comments
python:select interpreterAnswers above won't change interpreter in the visual-studio's terminal as explained. You can see for yourself. (I'm on linux)
which python3 # /usr/bin/python3 You can't export a new PATH because it'll ruin your other commands. And neither you can directly change the 'python3' file via root privileges. It doesn't work that way.
Your best option is to reshape your system interpreter according to your needs.


