In this article we will discuss about how to set the working environment of PYTHON for Visual Studio, or you could say how to remove / troubleshoot the error called “We didn’t find any interpreters”.
I assume you installed Python through Visual Studio. All things are installed perfectly and now you that you are trying to create a new Python console project your code will not run/execute.
This article shows you how to set the environment of Python in visual studio and execute the code.
You got this message:
"We didn't find any interpreters."
And this screen in Visual Studio,
By default Visual Studio will not set the environment of Python. We have to set it manually.
Set by step implementation
Step 1
After creating a project your solution explorer will look as follows,
Step 2
Double click on StringPythonApplicaiton.py and enter following lines of code:
- VisitorName = "Welcome to Python (Visual Studio)"
- print(VisitorName+"\n\n")
The above Python code is very simple.
Line 1
A variable is created called “VisitorName” and stored value = “Welcome to Python (Visual Studio)”
Line 2
Display value of “VisitorName” on screen with the help of print command.
As you press the F5 key the following error appears:
Step 3
Click on Solution explorer and follow the steps.
After clicking on ADD / REMOVE PYTHON ENVIRONMENTS you will see the following dialog box. By default Visual Studio created a New Environment 1
Click OK now.
Step 4
In the above screen you can see OVERVIEW is selected by default now you have to click on dropdown list and select “CONFIGURE” option. See the below screen shot for the next step:
Select CONFIGURE and the following text boxes appear on the screen
SR.NO. | TEXTBOX TITLE | REMARKS |
1 | Description | Give your environment a name / title. Example:MyPython |
2 | PrefixPath | Main folder of Python installer. Example: C:\Users\admin\AppData\Local\Programs\Python\Python36-32\ |
3 | Interpreter Path | Interpreter path of Python Example: C:\Users\admin\AppData\Local\Programs\Python\Python36-32\python.exe |
4 | Window Interpreter Path | Window Interpreter path of Python Example:C:\Users\admin\AppData\Local\Programs\Python\Python36-32\pythonw.exe |
5 | Lib Path | Library path of Python Example:C:\Users\admin\AppData\Local\Programs\Python\Python36-32\Lib |
STEP 5
STEP 6
STEP 7 - Restart Visual Studio.
As you start again now click on solution explorer and expand PYTHON ENVIRONMENTS tab.
Your screen will look like the below screen shot.
STEP 8
Now double click on “StringPythonApplication.py” file and press F5 to execute the code.
Hope this article helped you and resolved your problem.