
If you want to learn Python programming on a Windows computer, setting up the right tools is your first step. You need to install Python, install Visual Studio Code (VS Code), add the official Python extension, and connect VS Code to the Python interpreter.
This beginner-friendly guide explains how to install Python and set up VS Code on Windows, step by step. You will also create your first Python file, run it in the integrated terminal, and learn how to check that everything is working correctly.
What You Need Before Starting
You do not need an expensive computer or paid software. The basic setup uses three separate components:
| Component | What it does | Where to get it |
|---|---|---|
| Python | The programming language and interpreter that runs your code | Python.org |
| Visual Studio Code | The code editor where you write and manage Python files | VS Code download |
| Python extension | Adds Python language support, IntelliSense, running and debugging tools to VS Code | Microsoft Python extension |
Important: Installing VS Code does not install Python. The Python extension also does not include the Python interpreter. You must install these components separately and then select the interpreter inside VS Code.
Step 1: Download and Install Python on Windows
For current Windows installations, Python’s official documentation recommends using the Python Install Manager. You can get it from the official Python downloads page or the Microsoft Store.
- Open the official Python downloads page.
- Find the Windows download option for the Python Install Manager.
- Download and open the installer, then follow the installation prompts.
- When installation finishes, open a new Windows Terminal, PowerShell, or Command Prompt window.
- Use the Python command to start Python. If no runtime is installed yet, the manager can install the current default runtime when automatic installation is enabled.
You can also install a runtime explicitly from the terminal:
py install
This installs the default Python runtime available through the manager. If you want to inspect available versions, use:
py list
py list --online
Use the Python Install Manager documentation for advanced options, older Windows environments, or managed computers where the standard MSIX installation is restricted.
Step 2: Verify That Python Is Installed
After installation, confirm that Windows can find Python. Open a new terminal window and run:
python --version
You should see a Python version number. You can also check the manager’s installed runtimes:
py list
If the version command works, Python is installed and available from your terminal. If it does not, review the Python Install Manager setup and troubleshooting instructions before continuing. Closing and reopening a terminal after installation is important because an already-open terminal may not have the updated PATH information.
Step 3: Download and Install Visual Studio Code
Now install the code editor you will use to write Python programs.
- Visit the official Visual Studio Code download page.
- Choose the Windows installer that matches your computer.
- Open the downloaded installer.
- Accept the license agreement and follow the setup wizard.
- Keep the recommended options unless you have a specific preference, then finish the installation.
- Launch Visual Studio Code from the Start menu.
VS Code is free to use and provides an integrated editor, terminal, extensions, and debugging features.
Step 4: Install the Microsoft Python Extension in VS Code
The Python extension connects VS Code to your Python installation and provides Python-specific development features.
- Open VS Code.
- Click the Extensions icon in the left Activity Bar.
- Alternatively, press
Ctrl + Shift + X. - Search for Python.
- Choose the extension published by Microsoft.
- Click Install and wait for the installation to finish.
The extension adds features such as code completion, IntelliSense, interpreter selection, running Python files, and debugging. You may also see Pylance recommended for language support; follow the extension recommendations shown by VS Code.
Step 5: Create Your First Python Project Folder
It is a good habit to keep each programming project in its own folder. This makes your files easier to manage and helps you create a separate virtual environment later.
- Create a folder on your computer named
PythonProjects. - Open VS Code.
- Select File → Open Folder.
- Browse to the
PythonProjectsfolder and open it. - If VS Code asks whether you trust the folder, review the prompt and confirm only if you trust its contents.
Your project folder is now the VS Code workspace. You can create Python files and folders inside it using the Explorer panel.
Step 6: Select the Python Interpreter in VS Code
VS Code needs to know which Python installation should run your programs. This is called selecting the Python interpreter.
- Press
Ctrl + Shift + Pto open the Command Palette. - Type Python: Select Interpreter.
- Choose the command from the list.
- Select the Python installation you just installed.
- Check the Python version or environment shown in the VS Code Status Bar.
If more than one Python version appears, choose the one you intend to use for this project. Later, when you create a virtual environment, you can select that project’s .venv interpreter instead.
If the interpreter does not appear, make sure Python is installed, the Microsoft extension is enabled, and you have opened the correct project folder. For more help, see our guide: Python Interpreter Not Found in VS Code? 7 Ways to Fix It.
Step 7: Create Your First Python File
Let’s create a simple program to check that your setup works.
- In the VS Code Explorer panel, click the New File icon.
- Name the file
hello.py. - Enter the following Python code:
print("Hello, Python!")
print("I am learning Python in VS Code.")
print("My first program is working!")
Save the file by pressing Ctrl + S. The .py extension tells VS Code that this is a Python source file.
Step 8: Run Your Python Program in VS Code
There are two beginner-friendly ways to run your program.
Method 1: Use the Run Python File button
- Open
hello.pyin the editor. - Click the Run Python File play button in the top-right corner.
- VS Code opens the integrated terminal and runs the file using the selected interpreter.
- Check the output in the terminal.
Method 2: Run the file from the terminal
- Open Terminal → New Terminal.
- Make sure the terminal is in the folder containing
hello.py. - Run this command:
python hello.py
Your output should look like this:
Hello, Python!
I am learning Python in VS Code.
My first program is working!
If you see these lines, your Python installation, VS Code extension, selected interpreter, and project file are working together.
Step 9: Create a Virtual Environment for Your Projects
Once your first program runs successfully, the next recommended step is to create a virtual environment for each project. A virtual environment keeps project dependencies separate, reducing package-version conflicts between different projects.
In VS Code, open the Command Palette and run Python: Create Environment. Choose Venv, then select the Python interpreter you want to use. VS Code creates a .venv folder in your workspace and can select it for the project.
You can also create it from the terminal:
py -m venv .venv
For a full walkthrough, including activation commands and package installation, read: How to Create a Python Virtual Environment in VS Code (Windows, macOS & Linux).
Common Python and VS Code Setup Problems
| Problem | Possible solution |
|---|---|
python is not recognised |
Open a new terminal, check that the Python Install Manager and runtime are installed, and review the PATH configuration. |
| VS Code does not show a Python interpreter | Install or enable the Microsoft Python extension, confirm Python is installed, and run Python: Select Interpreter again. |
| Run Python File button is missing | Open a .py file and check that the Microsoft Python extension is enabled. |
| Terminal opens in the wrong folder | Use File → Open Folder to open your project workspace, then open a new integrated terminal. |
| Python runs a different version | Use py list to inspect installed versions and select the intended interpreter in VS Code. |
| A package import fails | Confirm that the correct interpreter or virtual environment is selected, then install the package into that environment. |
Frequently Asked Questions
Is Python included with Visual Studio Code?
No. Python is installed separately. VS Code is the editor, and the Microsoft Python extension adds Python development features. You need all three components for the setup described in this guide.
Is VS Code free for Python programming?
Yes. You can download and use Visual Studio Code for free, and the official Microsoft Python extension is available through the Visual Studio Marketplace.
Which Python version should beginners install?
For a new project, choose a current stable Python release supported by the packages and learning materials you plan to use. If a course or project specifies a particular version, follow that requirement.
How do I check my Python version in VS Code?
Open the integrated terminal and run python --version. You can also run py list to view Python runtimes managed by the Python Install Manager.
Do I need the Python extension to run Python code?
You can run Python from a terminal without the VS Code extension, but the Microsoft Python extension provides editor integration such as interpreter selection, code completion, running files, and debugging.
What should I learn after installing Python and VS Code?
Start with Python variables, data types, conditions, loops, functions, lists, dictionaries, and file handling. Then learn virtual environments and package installation before moving on to web development, automation, or data analysis.
Conclusion
You have now installed Python and Visual Studio Code on Windows, added the Microsoft Python extension, selected an interpreter, and run your first Python program. This setup gives you a practical starting point for learning Python and building your own projects.
Keep your projects organized, use a separate virtual environment when you start working with packages, and practise by creating small programs regularly. Once you are comfortable with the basics, you can explore Python automation, web development, data analysis, and more.
Official References
- Download Python and Python Install Manager
- Python documentation: Using Python on Windows
- Download Visual Studio Code
- Getting Started with Python in VS Code
- Microsoft Python extension for VS Code
