You now have Visual Studio Code and Python installed on your computer. But they are still separate tools.
In this step, you will add Python support to VS Code, choose the Python interpreter you installed, and confirm exactly which Python VS Code is using.
What you will finish: VS Code will show your selected Python interpreter, and you will print its path and version inside VS Code.
1. Open Extensions in Visual Studio Code
Open Visual Studio Code.
On the left side of the window, select the Extensions icon. You can also press:
Ctrl + Shift + X
In the search box, type:
Python
2. Install the Microsoft Python Extension
Look for the extension named Python published by Microsoft. Check the publisher before selecting Install.
You may also notice related Microsoft extensions such as Pylance, Python Debugger, or Python Environments. That is normal. The Python extension currently installs several related extensions automatically to provide Python language, debugging, and environment features.
For now, do not configure them. We only need the basic Python connection.
3. Select the Python Interpreter
An interpreter is the actual Python program that runs your Python code. VS Code needs to know which one to use.
Press:
Ctrl + Shift + P
This opens the Command Palette. Type:
Python: Select Interpreter
Select that command.
VS Code will show the Python installations it can find. Choose the Python 3 version you installed in the previous article.
Your version number and file path may look different from the screenshot. That is normal. What matters is that you select the Python installation you intend to use.
4. Check Which Python VS Code Is Using
We will check the connection without creating a Python file yet.
Your first .py file will come in the next article.
Press Ctrl + Shift + P again and run:
Python: Start Terminal REPL
A terminal will open with a Python prompt that looks like this:
>>>
Type these three lines one at a time:
import sys
print(sys.executable)
print(sys.version)
The first result is the exact Python executable VS Code is using. The second result shows the Python version.
A result might look roughly like this:
C:\...\python.exe
3.x.x (...)
Do not worry if your path or version is different. Your goal is simply to see a real Python path and a Python 3 version.
When you are finished, type:
exit()
Check Your Result
You have completed this step if all three statements are true:
- The Microsoft Python extension is installed.
- A Python 3 interpreter is selected in VS Code.
sys.executableandsys.versionprint successfully inside VS Code.
One Common Problem: More Than One Python Appears
This is common. Windows may contain more than one Python installation.
If you see several choices, select the Python 3 version you installed in the previous step.
After selecting it, use sys.executable again. The printed path tells you exactly
which Python VS Code is using.
If the Python you installed does not appear at all, close VS Code and open it again.
Then run Python: Select Interpreter once more.
What You Just Connected
Visual Studio Code is the editor. The Microsoft Python extension adds Python support. The Python interpreter actually runs the code.
These three pieces are now connected.
In the next step, you will create your first real Python file inside an
alphesta-lab folder and run it yourself.
Source note: The workflow follows current Microsoft Visual Studio Code documentation. The Python extension and Python environment interface can change over time, so some buttons or labels may look slightly different. Microsoft and Visual Studio Code names and logos are trademarks of their respective owners.