23

The small problem is, when I press Ctrl+F5, I want the code to be run immediately; but I have to

Select environment:

Python
Python Exprimental

all the time. Is there a way to set default env in settings so I don't have to choose at each run?

2
  • 1
    user1422543's answer is correct. Visual Code remembers the settings for a project/workspace using the .vscode/settings.json file which is in the root folder of the project. Once it is set, every time you open that project, vscode will set the right environment Commented Dec 13, 2019 at 12:51
  • Does this answer your question? In vscode using Python, ctrl+F5 always asks for "select environment" Commented Jul 4, 2020 at 9:10

4 Answers 4

21

Windows:

{
  "python.defaultInterpreterPath": "c:/dev/ala/venv/Scripts/python.exe"
}

macOS/Linux:

{
  "python.defaultInterpreterPath": "/home/abc/dev/ala/venv/bin/python"
}

vscode deprecated the python.pythonPath setting. Since the 2021.6.0 (16 June 2021) update we should use the above. The vscode documentation has already been updated.

Sign up to request clarification or add additional context in comments.

Comments

8

Once you selected an interpreter, it should be stored in the settings.json file in .vscode folder. It should be something like this:

{
  "python.pythonPath": "C:\\Users\\Username\\AppData\\Local\\Programs\\Python\\Python36\\python.exe"
}

Next time you use vscode to open this folder, the python interpreter you used last time should be automatically selected.

Maybe you didn't use "Open folder" to open the working directory. And then vscode will try to read the local .vscode folder if any, otherwise it will follow a certain path order to select an interpreter. Hope that helps.

1 Comment

NOTE: this solution is deprecated, see: stackoverflow.com/a/68467958/230468
6

File > Preferences > Settings > User tab > Extensions > python > Python Path

type your python path e.g.: c:\python35\python.exe

1 Comment

Should be using the Python extension default interpreter configuration (using something like pipenv) code.visualstudio.com/docs/python/…
0

press ctrl+shift+p to launch command pallete and

type python interpreter and you will get an option select interpreter

then select python interpreter

Choosing an environment By default, the Python extension relies on the first Python interpreter it finds in the path, but it's easy to switch between environments.

To use a specific interpreter, select the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

2 Comments

This does not help. I select the only one (python 2.7.14 64 bit interpreter), but when I press ctrl+f5 I get the choice between python and python experimental again.
then press ctrl+, open the setting and search for python, you wil get the option for setting the python interpreter where u give the full path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.