VS Code (graduation track)

Have you already done a few Python sessions and do you want more control over your code? Then VS Code is a good next step. It is the editor real programmers use too.

When to switch?

Only when Thonny starts to feel too limited, for example when you want to manage several files at once, want to use Git, or are just curious how professional developers work.

Switching is not required. Thonny stays fine for beginners and short sessions.

Tip: give VS Code a try once you have done at least 3 sessions and you’re comfortable with the basics of Python.

Installing VS Code

Download VS Code via code.visualstudio.com. Choose the installer for your operating system (Windows, macOS or Linux) and follow the installation steps.

Installing the Python extension

VS Code works with extensions. For Python you need the official Microsoft extension:

  1. Open VS Code.
  2. Click the Extensions tab in the sidebar (or press Ctrl+Shift+X).
  3. Search for ms-python.python.
  4. Click Install.

After installing, VS Code automatically recognises Python files and you get autocomplete, error messages and more.

Installing uv

uv is a fast Python package manager that works much more easily than the standard pip. Install it via astral.sh/uv.

Windows (PowerShell):

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

macOS / Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

Restart your terminal after installing so that the uv command is available.

Setting up the project

Open a terminal in VS Code (`Ctrl+`` or via Terminal → New Terminal) and run these commands in your project folder:

# Use Python 3.13, 3.14 or 3.15
uv init --python 3.14
uv add pgzero pygame-ce pygbag
Note

Use Python 3.13, 3.14 or 3.15. We install pygame-ce instead of pygame: that is the community version that also works on the newest Python. Pgzero however still asks for the classic pygame.

So put this line in your pyproject.toml, so that uv skips that old pygame:

[tool.uv]
exclude-dependencies = ["pygame"]

After that you have to tell VS Code which Python version the project uses:

  1. Press Ctrl+Shift+P and type Python: Select Interpreter.
  2. Choose the interpreter that is in your .venv folder (it looks like .venv/bin/python or .venv\Scripts\python.exe).

VS Code now uses the right environment with all the packages you just installed.

Running Pgzero

Open a terminal in VS Code and use:

uv run pgzrun main.py

Or create a launch.json in the .vscode/ folder so you can start with F5:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Pgzero: run current file",
      "type": "debugpy",
      "request": "launch",
      "module": "pgzero",
      "args": ["${file}"],
      "console": "integratedTerminal"
    },
    {
      "name": "Pygame: run current file",
      "type": "debugpy",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal"
    }
  ]
}

Create the .vscode/ folder in your project folder if it isn’t there yet, and save the file as launch.json. You then see the configurations back in the Run and Debug panel (Ctrl+Shift+D).

Running Pygame

For normal Pygame projects (without pgzrun) you use:

uv run python main.py

Or choose the “Pygame: run current file” configuration in the Run and Debug panel if you have created the launch.json.