How to configure Visual Studio code to search for Python 3 interpreter in Windows 10

In Windows 10, how to configure Visual Studio code to search for a Python 3 interpreter. In Windows 10, Visual Studio code does not find a Python 3 interpreter. I added the Python extension, which can be found at https://marketplace.visualstudio.com/items?itemName= donjayamanne.python . How to edit settings.js to use Python? Even if python.pythonPath in settings.js is changed to lead to python.exe, which in Windows 10 is "C: \ Users \\ AppData \ Local \ Programs \ Python" \ Python36-32 \ python.exe. VS code when typing Python: Select Workspace Interpreterin the command palette, displays the message " Please open a workspace to select the Python Interpreter". Why?

+21
source share
6 answers

Macos

VSCode -> Preferences -> Preferences -> scroll down to Python Configuration.

Click on the pencil to the left of the configuration that you want to use and click "Copy Settings."

"python.pythonPath": "python3.6"

enter image description here

enter image description here

+30
source

Go to File/Preferences/Settingsand find Python Configuration. Here you can manually change the settings.

You can also choose a translator from command palette. The following instructions are from DonJayamanne Github .

Select a command Python: Select Workspace Interpreterfrom the command palette.

After selecting the above command, the list of detected translators will be displayed in the quick selection list.

Selecting a translator from this list will automatically update the file settings.json.

Command Pallet Screenshot

+6

Python Visual Studio Windows 10. Python C:\Python27\ C:\Python36 \, Windows PATH. VS Code Python. , .

VS , , 3.6. 2,7 , VS Code settings.json VS Code Ctrl ,, :

{
"python.pythonPath": "c:/python27/python.exe"
}

- - Python .

Wiki " " . Python 2.7.

-, , , Python , , Select an Interpreter.

+3

, VS Code, .vscode/settings.json json:

 {
    "python.pythonPath": "path_to_your_python_bin", 
    # e.g., /home/myname/venv/bin/python3.7 or to a .exe file if you are on Windows
 }
+1

. , @jps, , , Python36 Python27, .

0

In my case, I saw the actual workspace in which you are working, overriding File / Settings / Settings (Windows) or Code / Settings / Settings (Mac).

The solution was to manually edit the workspace file (usually in your home directory) or create a new workspace and re-add the directory for your code.

0
source

Source: https://habr.com/ru/post/1016429/


All Articles