Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in Windows 10, How to configure Visual Studio Code to find the Python 3 interpreter?

In Windows 10, How Visual Studio Code should be configured to find the Python 3 interpreter?

Visual Studio Code is not able to find the Python 3 interpreter.

I have added the Python extension, the Python extension at https://marketplace.visualstudio.com/items?itemName=donjayamanne.python.

How settings.js should be changed to use Python?

Even if python.pythonPath in settings.js is changed to be led to python.exe, which is at "C:\Users<User>\AppData\Local\Programs\Python\Python36-32\p‌ython.exe", if I select Python: Select Workspace Interpreter in the command palette, I get the message Please open a workspace to select the Python Interpreter. Why is this happening?

like image 631
Varuna Avatar asked Apr 10 '17 01:04

Varuna


People also ask

How do I find the Python interpreter in VS Code?

Select and activate an environment# To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P). Note: If the Python extension doesn't find an interpreter, it issues a warning.

How do I get Python 3 in VS Code?

Click on the Extension button on the left-hand menu bar. The Marketplace for VS Code Extensions should open up. Search for python in the search bar. Choose the Python extension provided by Microsoft and click on “Install”.

Why is Python interpreter not showing in VS Code?

Install Python and the Python extension# Once you have a version of Python installed, activate it using the Python: Select Interpreter command. If VS Code doesn't automatically locate the interpreter you're looking for, refer to Environments - Manually specify an interpreter.

How do I add Python interpreter to Visual Studio?

Select the Add Environment command in the Python Environments window or the Python toolbar, select the Python installation tab, indicate which interpreters to install, and select Install. You can also manually install any of the interpreters listed in the table below outside of the Visual Studio installer.


3 Answers

macOS

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

Click the pencil on the left of the configuration you'd like to use and click Copy Settings.

"python.pythonPath": "python3.6"

enter image description here

enter image description here

like image 102
Edison Avatar answered Oct 05 '22 03:10

Edison


Go to File/Preferences/Settings and find Python Configuration. This is where you manually change the configurations.

You can also select your interpreter from command palette. The following instructions are from DonJayamanne's Github.

Select the command Python: Select Workspace Interpreter from the command palette

Upon selecting the above command a list of discovered interpreters will be displayed in a quick pick list

Selecting an interpreter from this list will update the settings.json file automatically.

Command Pallet Screenshot

like image 45
Cabara Avatar answered Oct 05 '22 03:10

Cabara


In the current directory where you open you VS Code, go to .vscode/settings.json and modify this line in the json file:

 {
    "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
 }
like image 27
thanhtang Avatar answered Oct 05 '22 04:10

thanhtang