If you just got a Raspberry Pi and want to start writing Python code, Thonny is the easiest way in. It comes pre-installed on Raspberry Pi OS, it was built specifically for learning Python, and it removes the clutter that bigger editors throw at beginners. Getting your Raspberry Pi Thonny IDE setup right means you can go from unboxing to running your first script in minutes no terminal commands required. This matters because the sooner you can write and run code, the sooner you start building real projects with sensors, LEDs, and automation.

What Is Thonny and Why Does Raspberry Pi Include It?

Thonny is a lightweight Python IDE created by Aivar Annamaa at the University of Tartu in Estonia. It was designed from the ground up for people who are new to programming. Unlike editors such as VS Code or PyCharm, Thonny hides advanced features behind a simple layout. You get one file open at a time, a clear run button, and a built-in shell that shows exactly what your code does, step by step.

Raspberry Pi includes Thonny by default in Raspberry Pi OS (formerly called Raspbian) because it pairs well with the Pi's educational mission. Whether you're a student, a teacher, or someone exploring Python programming basics on the Raspberry Pi, Thonny gives you a low-friction starting point.

How Do I Open Thonny on My Raspberry Pi?

Once your Raspberry Pi boots into the desktop, click the raspberry icon in the top-left corner. Navigate to Programming, then click Thonny Python IDE. That's it Thonny opens with a blank editor window and a shell panel at the bottom.

If you're running Raspberry Pi OS Lite (no desktop), Thonny won't be available. You'll need either the full desktop version of the OS or you can install Thonny manually using the terminal.

What if Thonny isn't installed on my Raspberry Pi?

Open a terminal and run these commands:

  1. sudo apt update refreshes your package list.
  2. sudo apt install thonny downloads and installs the IDE.
  3. thonny launches it from the terminal (or find it in the menu after install).

This takes about one to two minutes on a Raspberry Pi 4 with a decent microSD card.

What Does the Thonny Interface Look Like?

When Thonny opens, you'll see two main areas. The top area is the editor, where you write your Python scripts. The bottom area is the Shell (sometimes called the REPL), where Python runs your code and shows output. Think of the editor as your notebook and the shell as the place where answers appear.

Key buttons on the toolbar include:

  • Run (green play button) executes the script in the editor.
  • Stop (red button) interrupts a running program.
  • Debug button steps through your code line by line.
  • New/Open/Save standard file operations.

The default font used in Thonny's editor is clean and readable. If you prefer a different coding typeface, the built-in settings let you adjust the font and size under Tools → Options → Editor. Some developers like switching to a monospace style such as Source Code Pro or Fira Code for better readability of brackets and colons.

How Do I Write and Run My First Python Script in Thonny?

Type this into the editor window:

print("Hello, Raspberry Pi!")

Click the green Run button (or press F5). Thonny will ask you to save the file. Choose a name like hello.py and pick a folder. Once saved, you'll see the output in the Shell panel at the bottom.

That's your first program running on real hardware. From here, you can start controlling Raspberry Pi GPIO pins to blink LEDs, read sensors, or trigger relays all from inside Thonny.

How Do I Select the Right Python Interpreter in Thonny?

Newer versions of Raspberry Pi OS ship with both Python 2 and Python 3, though most current setups default to Python 3. To check which interpreter Thonny is using, look at the bottom-right corner of the window. It usually says something like Python 3.x.x.

If you need to switch:

  1. Go to Tools → Options → Interpreter.
  2. Select Standard CPython (default) for regular Python 3.
  3. Select MicroPython (Raspberry Pi Pico) if you're programming a Pico board connected via USB.

This interpreter setting is important. If you're working with a Raspberry Pi Pico, Thonny's built-in MicroPython support lets you flash firmware and write code for the Pico directly a feature that saved many beginners from dealing with complex toolchains.

Can I Use Thonny to Control GPIO Pins and Hardware?

Yes. The gpiozero library, which comes pre-installed on Raspberry Pi OS, works perfectly inside Thonny. You can write a script to blink an LED, read a button press, or control a servo motor all from the Thonny editor.

Here's a simple LED blink example:

from gpiozero import LED
from time import sleep

led = LED(17)

while True:
led.on()
sleep(1)
led.off()
sleep(1)

Run this in Thonny, and an LED connected to GPIO pin 17 will blink on and off every second. If you need a refresher on which pin does what, check out the GPIO pinout reference sheet.

What Common Mistakes Do Beginners Make in Thonny?

After helping dozens of people set up their first Raspberry Pi coding environment, here are the mistakes that come up most often:

  • Running code without saving first. Thonny prompts you to save, but some people cancel this and then wonder why their file is gone. Always save your script before running it.
  • Using the wrong Python version. If your code uses Python 3 syntax (like print() with parentheses) but Thonny is set to Python 2, you'll get confusing errors. Check the interpreter setting.
  • Confusing the editor and the shell. If you type code directly into the Shell panel, it runs immediately but isn't saved as a file. Write your programs in the editor window above.
  • Indentation errors. Python uses indentation (spaces) to define code blocks. Thonny auto-indents after colons, but if you copy-paste code from the web, the spacing might break.
  • Forgetting to install libraries. If you import a module that isn't installed, Thonny will show a ModuleNotFoundError. Use the built-in package manager under Tools → Manage packages to install missing libraries.

How Do I Install Additional Python Packages in Thonny?

Thonny has a built-in package manager that uses pip behind the scenes. Go to Tools → Manage packages, type the name of the library you need (for example, requests or matplotlib), and click Install.

Alternatively, you can open a terminal and run:

pip3 install package-name

Both methods work. The Thonny interface is more approachable if you're not comfortable with the terminal yet.

Is Thonny Good Enough for Real Projects?

For learning, prototyping, and small-to-medium Raspberry Pi projects, Thonny works well. The step-through debugger is genuinely useful it lets you watch variables change as each line runs, which is something many advanced editors don't show as clearly.

Where Thonny starts to feel limited is on larger codebases with multiple files, virtual environments, or version control. When you reach that point, moving to an editor like VS Code is a natural next step. But for getting started and building your first handful of hardware projects, Thonny removes enough friction to keep you moving.

Quick Setup Checklist

  • Boot your Raspberry Pi into the full desktop version of Raspberry Pi OS.
  • Open Thonny from Menu → Programming → Thonny Python IDE.
  • Verify the interpreter (bottom-right corner) shows Python 3.
  • Write a print("Hello") test script and run it with F5.
  • Save your script to a dedicated folder (like /home/pi/projects/).
  • Test a GPIO script using gpiozero to confirm hardware access works.
  • Use Tools → Manage packages to install any libraries your project needs.

Next step: Once your Thonny environment is running, pick one physical computing project blinking an LED is the classic starting point and build it from start to finish inside Thonny. Completing one full project teaches you more than reading ten tutorials.