How to Set Up Visual Studio Code for Python on Windows 11

If you’re starting your Python journey or want a lightweight yet powerful coding environment, Visual Studio Code (VS Code) is one of the best tools available. It’s fast, customizable, and integrates seamlessly with Python to provide an excellent development experience.

In this guide, we’ll show you how to install and set up VS Code for Python on Windows 11 — step by step. By the end, you’ll have a fully configured environment ready to write, run, and debug Python code.

Why Use Visual Studio Code for Python?

Visual Studio Code, developed by Microsoft, is one of the most popular text editors for developers — and for good reason. When combined with the Python extension, it turns into a full-fledged IDE.

Benefits of Using VS Code for Python:

  • Lightweight and fast — unlike heavy IDEs like PyCharm.
  • Extensions and customization for any workflow.
  • IntelliSense — smart code completion and suggestions.
  • Built-in debugger for easy error tracking.
  • Integrated terminal for running Python scripts directly.
  • Cross-platform — works on Windows, macOS, and Linux.

Step 1: Install Python on Windows 11

Before setting up VS Code, ensure that Python is installed on your system.

Steps to Install Python:

  1. Go to the official Python website: https://www.python.org/downloads/
  2. Click on Download Python 3.x.x (latest version).
  3. Run the downloaded installer.
  4. In the setup window, make sure to check:
    • Add Python to PATH
    • Install for all users
  5. Click Install Now and wait for the installation to finish.

Verify the Installation:

Open Command Prompt (CMD) and type:

python --version

If Python is installed correctly, you’ll see something like:

Python 3.12.1

Pro Tip: If you get an error like “Python not recognized”, you may need to add it manually to your PATH — see How to Add Python to PATH on Windows 11.

Step 2: Download and Install Visual Studio Code

Once Python is installed, let’s set up Visual Studio Code.

  1. Visit the official download page: https://code.visualstudio.com/
  2. Click Download for Windows.
  3. Run the installer and follow the setup wizard.
  4. During installation, check these options:
    • ✅ Add “Open with Code” to File Explorer context menu.
    • ✅ Add to PATH (so you can open VS Code from CMD).

After installation, launch VS Code.

Step 3: Install the Python Extension in VS Code

VS Code doesn’t support Python out of the box — you’ll need to install the Python extension from Microsoft.

  1. Open VS Code.
  2. Click on the Extensions icon on the left sidebar (or press Ctrl + Shift + X).
  3. In the search bar, type: Python
  4. Install the extension published by Microsoft (it should be the top result).
  5. Once installed, reload VS Code.

Pro Tip: The Python extension automatically adds support for IntelliSense, Linting, Jupyter Notebooks, and Debugging.

Step 4: Install the Python Extension Pack (Optional but Recommended)

For a complete Python development setup, install the Python Extension Pack — it bundles multiple tools useful for coding, formatting, and linting.

Includes:

  • Python (by Microsoft)
  • Pylance (for better IntelliSense)
  • Jupyter
  • Python Debugger
  • Black Formatter
  • isort (import sorter)

To install:

  1. Go to the Extensions tab again.
  2. Search for: Python Extension Pack
  3. Click Install.

Step 5: Configure the Python Interpreter

VS Code needs to know which Python installation or virtual environment to use.

To select the interpreter:

  1. Open a Python file or create a new one (e.g., test.py).
  2. Press Ctrl + Shift + P to open the Command Palette.
  3. Type: Python: Select Interpreter
  4. Select the interpreter you installed earlier (e.g., Python 3.12 (C:\Python312\python.exe)).

If you have multiple Python versions installed, choose the one you want to use for your current project.

Step 6: Create Your First Python File

Now that everything’s ready, let’s create and run a simple Python script.

  1. In VS Code, click File → New File.
  2. Save it as hello.py.
  3. Add this code: print("Hello, Python from VS Code!")
  4. Click Run at the top-right corner, or open the integrated terminal (Ctrl + ~) and type: python hello.py

You should see:

Hello, Python from VS Code!

Step 7: Set Up Virtual Environments (Recommended)

Virtual environments help keep your project dependencies isolated — a must for managing multiple Python projects.

To create a virtual environment:

  1. Open the Terminal in VS Code (Ctrl + ~).
  2. Navigate to your project folder: cd path\to\your\project
  3. Create a virtual environment: python -m venv venv
  4. Activate it: venv\Scripts\activate
  5. Install any dependencies you need: pip install requests

Tip: When a virtual environment is activated, VS Code automatically detects it and uses it as the project’s Python interpreter.

Step 8: Enable Linting and Auto-Formatting

Code linting helps you detect potential issues and maintain clean code automatically.

Enable Linting:

  1. Press Ctrl + Shift + P → search for: Python: Enable Linting
  2. Select Yes.
  3. Choose a linter (like pylint or flake8).

Enable Auto-Formatting:

  1. Go to File → Preferences → Settings (Ctrl + ,).
  2. Search for “format on save”.
  3. Enable: Editor: Format On Save
  4. Select a formatter: Python > Formatting: Provider → Black

Now, your code will automatically format and highlight syntax issues as you type.

Step 9: Install Useful Python Extensions (Optional)

Here are a few more handy extensions for Python development in VS Code:

ExtensionPurpose
PylanceFast IntelliSense and type checking
JupyterRun Python notebooks inside VS Code
Black FormatterConsistent code formatting
isortOrganize imports automatically
Python Test ExplorerManage and run Python tests
PrettierGeneral code formatter

Step 10: Debug Your Python Code

VS Code’s built-in debugger makes it easy to inspect variables and fix bugs.

To debug:

  1. Click on the Run and Debug icon (or press Ctrl + Shift + D).
  2. Select Python File as the configuration.
  3. Set breakpoints by clicking next to the line numbers.
  4. Press F5 to start debugging.

You can inspect variables, view the call stack, and step through your code interactively.

Step 11: Run Python Code in Jupyter Notebooks (Optional)

VS Code supports Jupyter Notebooks (.ipynb) directly.

  1. Install the Jupyter extension (if not already).
  2. Open or create a .ipynb file.
  3. You’ll see Run Cell options above each code block.
  4. Execute your cells interactively — just like in JupyterLab.

Pro Tip: Perfect for data science, ML, or AI projects.

Wrapping Up

That’s it! You’ve now successfully learned how to set up Visual Studio Code for Python on Windows 11.

With the Python extension, IntelliSense, virtual environments, and integrated debugging, VS Code gives you a powerful yet simple Python development setup.

Whether you’re learning Python, building AI models, or developing full-stack web apps — this setup will help you code smarter, faster, and cleaner.

Posted by Arpita

With a background in Computer Science, she is passionate about sharing practical programming tips and tech know-how. From writing clean code to solving everyday tech problems, she breaks down complex topics into approachable guides that help others learn and grow.