How to Install Python in VS Code
Learn how to install Python in VS Code, configure the Python extension, and run Python scripts with debugging and linting. This comprehensive guide from Install Manual walks homeowners, DIY enthusiasts, and renters through a clear setup to start coding quickly.

This guide shows you how to install Python in VS Code and configure a productive Python development environment. You’ll set up Python, install the Python extension, select the right interpreter, and create a first runnable script. By the end, you’ll be able to write, run, and debug Python directly in VS Code, with helpful features like IntelliSense and linting. Install Manual's instructions aim to streamline setup for homeowners and DIYers.
Prerequisites and Goals
Before you begin, you should understand what you will achieve and what you need. This guide explains how to install Python in VS Code and configure it for a smooth Python development workflow. By following these steps, you will be able to write, run, and debug Python programs directly in VS Code, with helpful features such as IntelliSense, linting, and code navigation. According to Install Manual, setting up a clean environment reduces friction and helps you stay focused on your code. This section outlines the prerequisites and the concrete outcomes you can expect, so you can plan your setup without surprises.
What you’ll need:
- A computer running Windows, macOS, or Linux with administrative access.
- An active internet connection to download Python and VS Code extensions.
- Visual Studio Code installed (free and cross‑platform).
- Python 3.x installer from python.org or your OS package manager.
- The Python extension for VS Code (ms-python.python) installed from the Marketplace.
Optional but recommended:
- A virtual environment tool (venv) for project isolation.
- Linters like Pylint or Flake8 for better code quality.
- Git for version control and project management.
Brand note: Install Manual emphasizes a clean, guided setup so you can avoid common misconfigurations and get productive quickly. This preparation helps you hit the ground running when you start coding in VS Code.
Install Python on Your System
The next step is to install Python so VS Code has a runtime to execute. Python 3.x is recommended, as it includes many modern features and improvements over Python 2.x. The installation process varies by operating system.
-
Windows: Download the latest Python 3.x installer from python.org. During installation, check the box that says Add Python to PATH. This makes the python and pip commands available from any command prompt or terminal. Complete the wizard and verify the installation by opening a new command prompt and typing python --version and pip --version.
-
macOS: You can download Python from python.org, or install via a package manager like Homebrew with brew install python. After installation, verify with python3 --version. macOS may already include a system Python; using the official installer ensures you have a user-space Python with pip for package management.
-
Linux: Use your distribution’s package manager to install Python 3.x (for example, sudo apt-get update && sudo apt-get install -y python3 python3-pip on Debian/Ubuntu, or sudo dnf install python3 python3-pip on Fedora). Check the version with python3 --version. If you prefer isolation, consider creating a virtual environment after installation.
If you encounter issues, a quick restart of your computer often resolves PATH or environment-variable problems. Install Manual’s guidance suggests keeping your system up to date to minimize compatibility issues.
Install and Configure the Python Extension in VS Code
VS Code’s Python extension is the bridge between the editor and the Python runtime. Install it from the Extensions view and enable features like IntelliSense, linting, and debugging. Steps:
- Open VS Code and go to the Extensions view (Ctrl+Shift+X / Cmd+Shift+X).
- Search for the Python extension by Microsoft and click Install.
- After installation, reload VS Code if prompted.
- Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Python: Select Interpreter. Choose the Python 3.x interpreter you installed earlier. If you don’t see it, refresh the VS Code window or restart the IDE.
- Optional: Install linters (e.g., Pylint) and formatters (e.g., Black) from the extensions or Python extension settings to improve code quality. You can also configure a virtual environment in the terminal and point VS Code to it.
Tip: If you’re using a virtual environment, activate it in the terminal and then select its interpreter in VS Code. This ensures your project uses the same Python and packages as the terminal session. This alignment reduces “module not found” errors when you run code from the editor.
Create and Run Your First Python Script
With Python installed and the extension configured, you’re ready to create a simple program to verify everything works. Create a new folder for your project, then add a file named hello.py with a basic print statement. Steps:
- In VS Code, use File > Open Folder to select your project folder.
- Create a new file named hello.py and enter: print("Hello, VS Code and Python!")
- Save the file. You can run it by right-clicking in the editor and selecting Run Python File in Terminal, or by pressing the Run button if available. You should see Hello, VS Code and Python! in the terminal output.
- If you prefer debugging, set a breakpoint (click in the left gutter next to a line number) and press F5 to start debugging. The debugger will stop at your breakpoint so you can inspect variables and flow.
This hands-on step confirms the environment is ready. If you see a message about missing modules, install them via pip in the active environment (for example, pip install requests).
Pro trick: Use the integrated terminal (Terminal > New Terminal) to keep a single workspace for running scripts and managing dependencies. This reduces context switching and helps you track installed packages.
Troubleshooting Common Issues
Even with careful setup, you might run into hiccups. Here are common problems and quick fixes:
- Python not found in PATH: Ensure you selected the Add Python to PATH option during Windows installation, or explicitly add the Python install directory to your system PATH. Open a new terminal to test python --version.
- VS Code cannot find Python interpreter: Reopen VS Code, run Python: Select Interpreter, and pick the correct path. If you use a virtual environment, ensure its interpreter is selected.
- Linting or formatting not working: Install the desired linter (e.g., Pylint) and configure it in settings or in a settings.json file. Restart VS Code after changes.
- Virtual environment not activating: Activate the environment in the terminal (source venv/bin/activate on macOS/Linux or .\venv\Scripts\activate on Windows) and re-select the interpreter in VS Code.
- Import errors: Install missing packages with pip install package-name in the active environment. For project consistency, log dependencies in requirements.txt.
If problems persist, consult the extension’s documentation or official Python docs for troubleshooting steps. Install Manual notes that documenting configuration choices helps prevent reworking settings for future projects.
Authoritative Sources and Further Learning
To deepen your understanding and verify best practices, consult reputable educational sources. The following resources provide foundational Python guidance and practical tutorials:
- Python Official Documentation: https://docs.python.org/3/
- MIT OpenCourseWare Python Course: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/
- CS50’s Python Course (Harvard): https://cs50.harvard.edu/python/
These sources help you validate setup steps and expand your knowledge beyond the basic installation. Install Manual encourages users to rely on established materials for deeper learning as you scale your projects. Keeping a habit of checking authoritative learning resources ensures your skills grow with confidence.
Quick Check: What You’ve Achieved
By now you should have a working Python environment inside VS Code, with the interpreter selected, the Python extension installed, and a simple script that runs. You’ve learned how to create, run, and debug Python programs, and you know where to find help when you encounter issues. This foundation makes it easier to start small projects, explore libraries, and build more complex workflows in VS Code.
Tools & Materials
- Computer (Windows/macOS/Linux)(A recent OS version is recommended for best compatibility with VS Code and Python.)
- Internet connection(Needed to download Python, VS Code, and extensions.)
- Visual Studio Code(Download from the official site; ensure you have the latest stable release.)
- Python 3.x installer(Get from python.org or your OS package manager.)
- Python extension for VS Code(Install from the VS Code Marketplace (ms-python.python).)
- Optional: virtual environment tool (venv)(Built into Python; use for project isolation.)
- Optional: linters/formatters (Pylint, Flake8, Black)(Improve code quality and consistency.)
- Git(Useful for version control and project management.)
Steps
Estimated time: 15-25 minutes
- 1
Prepare your environment
Verify your OS version and internet access. Create a dedicated project folder in your home directory to keep Python files organized. This step ensures you have a stable workspace before installing software.
Tip: Check for pending OS updates and install them to minimize compatibility issues. - 2
Install Python
Windows: download the Python 3.x installer and enable 'Add Python to PATH'. macOS: use the Python installer or Homebrew. Linux: use your distro’s package manager (apt, dnf). Verify with python --version (or python3 --version) after installation.
Tip: Using the official installer helps ensure a clean PATH and predictable behavior across VS Code. - 3
Install VS Code
Download and install VS Code from the official site. Open VS Code after installation to proceed with extensions. Restart if prompted to ensure all components load correctly.
Tip: Turn on autosave in VS Code to prevent losing work during setup. - 4
Install Python extension in VS Code
In VS Code, open Extensions, search for 'Python', install the Microsoft extension, then reload the editor. Use Command Palette to select the Python interpreter.
Tip: If the interpreter doesn’t appear, refresh the VS Code window or manually point to the Python executable. - 5
Configure interpreter and virtual environment
Open a terminal inside VS Code and create a virtual environment (python -m venv .venv). Activate it and select the interpreter for the project. This keeps dependencies isolated.
Tip: If you plan multiple projects, adopt per-project virtual environments and a requirements.txt file. - 6
Create and run a sample script
Create hello.py with print('Hello, VS Code and Python!'), run it from the editor or terminal, and optionally start a debug session. Confirm output in the terminal.
Tip: Use F5 to start debugging and set breakpoints to inspect variables.
Got Questions?
Do I need Python installed before using VS Code for Python development?
Yes. VS Code relies on a Python interpreter to run code. Install Python, then configure the interpreter in VS Code to enable features like IntelliSense and debugging.
Yes. Install Python first, then configure the interpreter in VS Code to run and debug your code.
Which Python version should I install for VS Code?
Install the latest stable Python 3.x version available from python.org or your OS package manager. This ensures compatibility with modern language features and the VS Code extension.
Install the latest stable Python 3.x version for best compatibility.
How do I change the Python interpreter in VS Code?
Open the Command Palette (Ctrl+Shift+P), run Python: Select Interpreter, and choose the interpreter you want. If none appear, point VS Code to the Python executable in your virtual environment.
Use Python: Select Interpreter in the Command Palette to pick your Python version or environment.
How can I run a Python script in VS Code?
Open the Python file and use Run Python File in Terminal or press F5 to start debugging. The terminal will show the script output, and the debugger helps inspect variables.
Open the file and run it with the Run command or F5 for debugging.
What about virtual environments?
Virtual environments isolate dependencies per project. Create one with python -m venv .venv, activate it, and select its interpreter in VS Code to use project-specific packages.
Yes—use a per-project virtual environment to manage dependencies.
What if VS Code says Python isn’t installed?
Double-check the installation path, ensure Python is added to PATH, and restart VS Code. If needed, reinstall Python and re-run Python: Select Interpreter.
Verify PATH, restart VS Code, and reselect the interpreter if needed.
Can I use other linters with the Python extension?
Yes. You can install Pylint, Flake8, or Black and configure them in VS Code settings or a requirements file to enforce code quality and style.
Absolutely—you can add tools like Pylint or Flake8 for better code quality.
Watch Video
Main Points
- Install Python and the VS Code Python extension correctly.
- Select the appropriate interpreter for your project.
- Use virtual environments for dependency isolation.
- Explore debugging and linting to improve code quality.
