How To Configure Thonny For Python Development on Windows.

In this post we will look at how to configure Thonny for Python Development on Windows.

The best practice for Python development is to use Python virtual environments. Thonny makes this super easy with a built-in option — no need for command line if you prefer the GUI way.

Step-by-Step: Create a Local Virtual Environment in Thonny (Windows)

  1. Open Thonny on your Windows PC.
  2. Access the Interpreter settings — you have a couple of quick ways:
    • Click the Python version/interpreter name shown in the bottom-right corner of the Thonny window (e.g., it might say “Python 3.12 (bundled)” or similar).
    • OR go to the menu: Run → Configure interpreter…
    • OR go to Tools → Options…, then select the Interpreter tab on the left.
  3. In the Interpreter dialog that opens:
    • Make sure the dropdown at the top says something like “Which interpreter or device should Thonny use for running your code?” and select Local if it’s not already (e.g., “The same interpreter which runs Thonny (default)” or your bundled/system Python).
    • Look for the “New virtual environment…” link or button — it’s usually near the bottom of the dialog, often right below the interpreter selection or in a section for custom setups.
  4. Click New virtual environment (or the similar link/button):
    • Thonny will prompt you to choose an empty directory where the venv should be created.
      • Pick or create a folder for your project (e.g., C:\Users\John\MyPythonProjects\test_project).
      • It’s best to make a dedicated folder first (empty), then select it here — Thonny will create the venv structure inside it.
    • Confirm/OK — Thonny automatically runs python -m venv behind the scenes and sets it up.
  5. Once created:
    • Thonny switches your interpreter to this new venv automatically. You don’t have to run the “activate” script
    • The bottom-right corner now shows the venv path (e.g., “…\test_project\venv (Python 3.12)”).
    • You’re now in an isolated environment!

What You Can Do Next (All Local on Windows)

  • Install packages → Go to Tools → Manage packages… — search and install anything (e.g., requests, numpy, pygame). They go only into this venv, not your system/global Python.
  • Test code locally → Write Python scripts as usual and press F5 (Run) — it executes using the venv’s Python.
  • Switch venvs or back to default → Just reopen the Interpreter dialog (step 2) and pick a different one (Thonny remembers recently used venvs too).
  • Multiple projects → Create a separate venv folder for each project — switch interpreters as needed.

Quick Command-Line Alternative (If You Prefer Terminal)

If the GUI button doesn’t appear or you want more control:

  1. Open Command Prompt or PowerShell.
  2. Navigate to your project folder: cd C:\path\to\your\project
  3. Create the venv: python -m venv venv (creates a folder named venv).
  4. Back in Thonny → Interpreter dialog → select Alternative Python 3 interpreter or virtual environment (or browse to it).
  5. Point to the executable: C:\path\to\your\project\venv\Scripts\python.exe
  6. OK — Thonny uses it.

This keeps everything 100% local on Windows for testing logic, UI prototypes, data processing, etc., without touching your Pi Zero 2 W setup. When you’re ready to deploy Pi-specific code (with GPIO, etc.), just switch back to your Remote Python 3 (SSH) interpreter pointing to the Pi’s venv as we set up before.

If the “New virtual environment” option isn’t showing in your Thonny version (rare, but possible on very old installs), update Thonny from thonny.org first — recent versions have it reliably.

And Finally…

While much of the recent focus of this blog has been RPI Pico development, you may also have need for local Python development and Thonny provides a great UI for how to configure Thonny for Python Development.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts