Complete guide to configuring Python 3.x with Visual Studio Code on Windows 11

When working with Python on Windows 11, Visual Studio Code (VS Code) emerges as a powerful and versatile code editor. This guide walks you through configuring Python 3.x with VS Code, ensuring an optimal development

Written by: Leo Nguyen

Published on: October 21, 2025

When working with Python on Windows 11, Visual Studio Code (VS Code) emerges as a powerful and versatile code editor. This guide walks you through configuring Python 3.x with VS Code, ensuring an optimal development environment.

Step 1: Install Python 3.x

  1. Visit the Official Python Website
    Go to python.org and download the latest version of Python 3.x.

  2. Run the Installer
    Execute the downloaded installer. Make sure to check the box that says “Add Python to PATH” before proceeding with the installation. This step ensures that the Python interpreter is accessible from the command line.

  3. Verify Installation
    Open the Command Prompt by pressing Win + R, typing cmd, and hitting Enter. Type python --version to verify if Python is successfully installed. You should see the version number displayed.

Step 2: Install Visual Studio Code

  1. Download VS Code
    Visit the Visual Studio Code website and download the Windows version.

  2. Install the Application
    Run the installer and follow the setup prompts. Use the default settings, allowing VS Code to add to your PATH.

Step 3: Configure Visual Studio Code for Python Development

  1. Open VS Code
    Launch the application after installation.

  2. Install the Python Extension

    • Click on the Extensions icon in the Activity Bar (or press Ctrl + Shift + X).
    • Search for “Python” in the marketplace. The official extension from Microsoft should be the top result. Click on “Install” to add it.
  3. Install Additional Useful Extensions
    To enhance your development experience, consider adding the following extensions:

    • Pylance: Provides rich type information, auto-completions, and overall better performance.
    • Jupyter: If you plan to work with Jupyter notebooks, this extension is essential.

Step 4: Configure Python Interpreter

  1. Open the Command Palette
    Press Ctrl + Shift + P to open the Command Palette.

  2. Select Interpreter
    Type Python: Select Interpreter and select it. A list of installed Python interpreters will be displayed.

  3. Choose the Correct Interpreter
    Select the Python interpreter you installed earlier. If you have multiple environments, ensure to select the one corresponding to your project.

Step 5: Create a Python File and Run It

  1. Create a New File
    Click on “File” > “New File” or press Ctrl + N. Save the file with a .py extension (e.g., hello.py).

  2. Write Basic Python Code
    Enter a simple Python script, such as:

    print("Hello, World!")
  3. Run the Python Script

    • Open the integrated terminal by selecting View > Terminal or pressing Ctrl +.
    • Ensure that the terminal is in the same directory as your script using the cd command.
    • Run the script by typing python hello.py and pressing Enter.

Step 6: Setting Up a Virtual Environment

  1. Create a Virtual Environment
    In the terminal, navigate to your project folder and execute:

    python -m venv venv

    This command creates a directory named venv containing the Python interpreter and libraries necessary for your project.

  2. Activate the Virtual Environment
    To activate the environment, run:

    .venvScriptsactivate
  3. Install Packages
    You can now install packages using pip. For example:

    pip install requests

Step 7: Debugging

  1. Set Breakpoints
    Click to the left of the line number to set a breakpoint.

  2. Open Debug Panel
    Click on the Debug icon in the Activity Bar or press Ctrl + Shift + D.

  3. Configure Launch Settings
    Click on “create a launch.json file” and choose “Python File”.

  4. Start Debugging
    Press F5 to start debugging. Use the debug toolbar to control execution.

Step 8: Linting and Formatting

  1. Set Up Pylint or Flake8
    Ensure you have a linting tool installed:

    pip install pylint
  2. Enable Linting in VS Code
    Open settings by pressing Ctrl + , and search for “linting”. Ensure that “Python › Linting: Enabled” is checked.

  3. Auto-format Code with Black
    Install Black:

    pip install black

    In the settings, search for “formatting” and set “Python › Formatting: Provider” to “black”.

Step 9: Using Git for Version Control

  1. VS Code Git Integration
    Open the Source Control view by clicking the Source Control icon. Initialize a new repository if needed.

  2. Commit Changes
    Stage your changes using the “+” icon next to the files. Enter a commit message and click on the checkmark to commit.

  3. Push to Remote Repository
    Connect with a remote repository (like GitHub) and push your changes using:

    git remote add origin <repository-url>
    git push -u origin main

Step 10: Customize Your VS Code Workspace

  1. User and Workspace Settings
    You can customize your settings by navigating to File > Preferences > Settings. Adjust themes, font sizes, etc., to suit your preferences.

  2. Keyboard Shortcuts
    Familiarize yourself with keyboard shortcuts to improve productivity. Access shortcuts by clicking on “Keyboard Shortcuts” in the preferences.

  3. Install Themes
    Enhance the visual appeal by searching for and installing themes in the Extensions pane.

Step 11: Jupyter Notebooks Support

  1. Open a Jupyter Notebook
    Create a new file with a .ipynb extension to work with Jupyter notebooks.

  2. Access Notebook Interface
    Use the notebook interface to add cells, run code, and visualize data directly in VS Code.

  3. Utilize Interactive Features
    Leverage VS Code’s capabilities to explore data interactively, using libraries like Matplotlib and Pandas.

By following these steps, you’ll have a fully functional and efficient Python development environment using Visual Studio Code on Windows 11. Whether you’re building simple scripts or developing complex applications, this setup enables you to focus on coding with ease and efficiency.

Leave a Comment

Previous

FastAPI and SQLAlchemy: Building a Full-Stack REST API

Next

Crafting Your First FastAPI Application: A Beginner’s Guide