Can You Use Python on Raspberry Pico? 🐍

Yes—you can use Python on Raspberry Pico with MicroPython, a lightweight Python implementation made for microcontrollers. Install the right firmware, connect the Pico to an editor such as Thony, and you can write programs that control LEDs, read sensors, and run small robotics projects.

One fun surprise: after you save your program to the Pico as main.py, it can run whenever the board powers up—even without your computer attached. The key is understanding that Pico runs MicroPython, not full desktop Python, some familiar libraries and applications won’t fit.

Key Takeaways

  • Yes, Python works on Raspberry Pico: MicroPython is the usual choice; CircuitPython is another option for supported boards.
  • You don’t need a Raspberry Pi computer: A regular computer, a data-capable USB cable, and the Pico are enough to get started.
  • Use firmware made for your exact board: Pico, Pico W, Pico 2, and Pico 2 W can require different firmware builds.
  • Thony is a friendly first editor: It lets you run code, use the MicroPython shell, and save scripts to your board.
  • Pico is a microcontroller, not a desktop computer: It’s excellent for sensors, LEDs, and simple robots, but it can’t run every standard Python package.
  • Keep hardware safe: Pico GPIO uses 3.3 V logic; motors and other high-current devices need suitable driver circuitry.

Table of Contents


Quick Tips and Facts: Python on Raspberry Pico

If you’re learning robotic coding, Pico is a friendly way to connect Python to real-world electronics. Our 10 Essential Skills to Become a Robotic Coding Expert (2025) 🤖 guide covers the broader skills behind projects like these.

Quick fact What it means for you
Yes, you can use Python on a Raspberry Pico. The usual choice is MicroPython, a Python implementation designed for microcontrollers.
Pico runs firmware, not a desktop operating system. It won’t run desktop Python applications, but it can execute scripts that read sensors, control LEDs, and communicate with devices.
Install MicroPython firmware first. Download the correct UF2 file, connect the board while holding BOOTSEL, then copy the file to the RPI-RP2 drive.
Thony is a beginner-friendly editor. It can connect to the Pico, run code, and show the MicroPython REPL (interactive prompt).
Pico W adds wireless networking. Its Wi-Fi hardware makes it suitable for simple connected projects, with compatible firmware and libraries.
Pico also supports C and C++. MicroPython is convenient; C/C++ may suit projects that need tighter performance or low-level control.

The official Raspberry Pi MicroPython documentation and Pico getting-started project both describe MicroPython as a way to program Pico. One useful distinction: Pico is a microcontroller board, not a Raspberry Pi computer. It starts your program directly rather than booting a desktop OS.

Quick recommendation: Choose MicroPython and Thony for your first Pico project. If your project later needs precise timing, heavy computation, or direct access to lower-level features, you can assess C/C++ rather than forcing Python to do every job.

How Python Runs on the Raspberry Pico


Video: How to Setup a Raspberry Pi Pico and Code with Thonny.








The Pico’s RP2040 microcontroller executes MicroPython firmware. Your Python code runs on the board itself, using the firmware’s modules to access hardware such as GPIO pins, ADC inputs, PWM outputs, and serial buses.

That’s different from running a Python program on a laptop that merely sends commands to an Arduino. With MicroPython, the Pico can carry out its own instructions after you unplug it from your computer, as long as it has power.

MicroPython vs. CircuitPython vs. desktop Python

“Python on Pico” usually means MicroPython or CircuitPython, not full desktop CPython. The languages share familiar syntax, but their supported modules and hardware interfaces differ.

Option Best for Important distinction
MicroPython Direct Pico hardware control and compact embedded projects Official Raspberry Pico documentation and examples focus on MicroPython.
CircuitPython Accessible hardware projects and Adafruit’s ecosystem Board support and available libraries depend on the specific CircuitPython build.
CPython Desktop and server applications Standard desktop Python expects an operating system and resources that Pico does not provide.
C/C++ SDK Performance-sensitive or low-level firmware Uses a different development workflow from MicroPython.

The MicroPython project describes its implementation as designed for microcontrollers and constrained systems. That makes it Python-like, but not a drop-in replacement for every desktop Python package. A library that depends on pandas, a desktop OS, or large amounts of memory won’t automatically work on a Pico.

For an introduction to other programming approaches, see our coding languages resources.

What the Pico’s microcontroller can—and can’t—do

Pico is built to interact with hardware efficiently. It can read a button, sample a sensor, drive a display, or control a small robot. It is not designed to replace a laptop or a Raspberry Pi computer.

Pico is good at ✅ Pico is not designed for ❌
Reading switches and sensors Running a desktop environment
Controlling LEDs, servos, and simple motors with suitable drivers Running large desktop applications
Repeating a small control loop Using every package available from PyPI
Communicating over I²C, SPI, and UART Hosting resource-heavy websites or databases
Running standalone after code is saved to the board Providing built-in Wi-Fi on the standard Pico model

The Raspberry Pico specifications describe the hardware interfaces and RP2040 platform. For robotics, remember that the Pico’s GPIO is 3.3 V logic. A motor or other high-current load should be driven through appropriate circuitry, not directly from a GPIO pin.

Raspberry Pico Models and Python Compatibility


Video: Raspberry Pi – How to Begin Coding Python on Raspberry Pi.








Different Pico models support Python-based development, but the board’s hardware features affect which firmware and project code you should use. Always check the firmware’s board target before installing it.

Pico, Pico W, Pico 2, and Pico 2 W

Board Microcontroller family Wireless Python project considerations
Raspberry Pico RP2040 No A strong choice for learning GPIO, sensors, displays, and wired communication.
Raspberry Pico W RP2040 Wi-Fi and Bluetooth hardware Wireless features require compatible firmware and libraries.
Raspberry Pico 2 RP2350 No Use firmware built for Pico 2; check library and board support.
Raspberry Pico 2 W RP2350 Wireless Check firmware support for both the board and its wireless features.

The Raspberry Pico product pages list board-family features and specifications. Do not assume a UF2 firmware file for one model is correct for another. Board-specific code may also need small changes, especially for onboard LEDs and wireless interfaces.

Choosing a MicroPython or CircuitPython firmware

Firmware is the software layer that lets your Python code communicate with the Pico’s hardware. Choose a build intended for your exact board, then follow that firmware’s installation guidance.

Before flashing, check:

  • Board model: Pico, Pico W, Pico 2, or Pico 2 W.
  • Firmware project: MicroPython or CircuitPython.
  • Hardware support: Confirm that the features your project needs are available.
  • Library compatibility: Make sure the required module supports your firmware and board.

Use the official MicroPython downloads or the relevant CircuitPython downloads. A mismatched file can turn a quick setup into a USB detective story. Fortunately, the Pico’s BOTSEL mode gives you a straightforward route to reinstall suitable firmware.

What You Need to Program a Pico with Python


Video: Raspberry Pi PICO Python Tutorial! | How to Program the Pico on a Windows System.








You don’t need a Raspberry Pi computer. A regular Windows, macOS, or Linux computer, a data-capable USB cable, and the Pico are enough to get started.

USB cable, computer, and accessories

Have these ready:

  • Raspberry Pico board compatible with your chosen firmware.
  • USB data cable with the correct connector for your board. Some cables charge devices but do not transfer data.
  • Computer with internet access for downloading firmware and an editor.
  • Optional breadboard and jumper wires for external components.
  • Optional sensors or LEDs for project experiments. Check voltage and wiring before connecting them.

For early learning, the onboard LED and the Pico’s USB connection are enough. The Raspberry Pi getting-started project begins with the board’s built-in capabilities, so you can test your setup without building a component pile first.

Thony, VS Code, and other Python editors

Thony is a sensible first editor because it includes an interactive shell and makes it relatively easy to choose a MicroPython interpreter. The Thony website provides installation downloads and documentation.

Editor or tool Good fit Setup note
Thony Beginners and quick experiments Select the MicroPython interpreter for your board.
Visual Studio Code Developers who want a larger editor workflow Extensions, serial tools, and firmware workflow may require extra setup.
mpremote Command-line workflows Useful for interacting with MicroPython devices from a terminal.
Web-based tools Convenient browser workflows Support varies, and a USB connection and compatible browser may be required.

For a first session, keep it simple: Thony, the official firmware, and one Pico. You can move to VS Code or a command-line workflow once the board is responding.

Get Started: 7 Steps to Run Python on Raspberry Pico


Video: CircuitPython with Raspberry Pi Pico – Getting Started.








The basic setup is short: load MicroPython firmware, connect an editor, and run a tiny program. The Raspberry Pico Python documentation and Pico starter project provide official guidance.

1. Download the correct MicroPython firmware

Visit MicroPython downloads and select the firmware for your exact Pico model. Download the .uf2 file to your computer.

Check the board name before you continue. Pico and Pico W firmware are not interchangeable by assumption, and Pico 2 uses a different microcontroller family.

2. Connect the Pico in BOTSEL mode

  1. Disconnect the Pico from USB.
  2. Press and hold the BOOTSEL button.
  3. While holding it, connect the Pico to your computer with a USB data cable.
  4. Release the button when the board appears as a USB storage device.

The drive is commonly named RPI-RP2. If it doesn’t appear, try another cable or USB port before blaming the firmware.

3. Install firmware on the board

Drag the downloaded UF2 file onto the RPI-RP2 drive. The board will restart, and the drive will disappear after the firmware is copied.

That disappearance is expected: the board has left bootloader storage mode and restarted into MicroPython. Raspberry Pi’s official MicroPython setup documentation describes this firmware-based workflow.

4. Connect your editor to the Pico

Open Thony and choose the MicroPython interpreter for your board in its interpreter settings. Connect to the device’s serial interface if Thony does not select it automatically.

If the Pico-specific interpreter option is missing:

  • Update Thony using its official download page.
  • Disconnect and reconnect the board.
  • Check that the firmware installation completed.
  • Try another USB data cable.

5. Run a first Python command

In Thony’s Shell, enter:

print("Hello, Pico!")
``

Press Enter. If you see the text in the shell, your computer and Pico are communicating.

The shell is also a useful place to test short expressions, inspect values, and spot errors before saving a complete program.

### 6. Save and run a Python script

Create a new file containing:

```python
from machine import Pin
from time import sleep

led = Pin("LED", Pin.OUT)

while True:
 led.toggle()
 sleep(0.5)
``

Save it **to the Pico** as `main.py`, then run it. Many MicroPython setups automatically execute `main.py` when the board starts.

The `Pin("LED", Pin.OUT)` form is supported on common current Pico MicroPython builds. Older examples often use a board-specific GPIO number; if an LED example fails, check the firmware documentation for your model.

### 7. Make your program start automatically

Save your project to the Pico as `main.py` if you want it to run at startup. Keep a separate copy on your computer too.

**Why keep a backup?** A program that loops forever may make normal interaction awkward until you reset the board or reconnect through BOTSEL mode. A saved backup makes recovery less dramatic—and prevents the classic “it worked yesterday” mystery.

## Your First Raspberry Pico Python Projects

A good first project shows a clear cause-and-effect relationship: change one input or instruction, observe what the board does. These small exercises also build skills useful for [robotic sensors](https://roboticcoding.com/category/robotic-sensors/) and control projects.

### Blink the onboard LED

Start with the `main.py` blink example above. Change `sleep(0.5)` to `sleep(0.1)` and watch the LED blink faster; set it to `1` for slower flashes.

The first video linked at [#featured-video](#featured-video) also demonstrates blinking an LED, fading it with PWM, reading analog input, and communicating with displays. Its narrator compares Pico’s processing power with an Arduino Nano, but exact performance comparisons depend on the board revision, workload, firmware, and code. Treat the clip as a practical demonstration, not a universal benchmark.

### Read a button and control an LED

A button introduces digital input. Wire a pushbutton between a GPIO pin and ground, then configure an internal pull-up:

```python
from machine import Pin
from time import sleep

button = Pin(14, Pin.IN, Pin.PULL_UP)
led = Pin("LED", Pin.OUT)

while True:
 led.value(not button.value())
 sleep(0.02)
``

With a pull-up, the button input is normally high and becomes low when pressed. Depending on your wiring and board, you may need to adjust the pin or logic.

- **Use a breadboard** to keep connections tidy.
- **Check the pinout** for your exact board before wiring.
- **Avoid connecting 5 V signals directly** to Pico GPIO.

### Measure temperature and log sensor data

Pico boards include an onboard temperature sensor, accessible through the ADC on supported MicroPython builds. The reading is an estimate of the chip’s temperature, not a calibrated room thermometer.

For more useful environmental measurements, connect a compatible external sensor and follow its datasheet. For example, an I²C temperature sensor can teach you how to scan a bus, read registers, and convert raw values into human-readable units.

The video at [#featured-video](#featured-video) shows an onboard temperature demonstration. That’s a handy learning exercise, but for accurate measurements use a sensor designed and specified for the environment you need to measure.

## MicroPython Basics for Raspberry Pico

MicroPython uses familiar Python syntax, while hardware access comes from modules such as `machine`. The [MicroPython documentation](https://docs.micropython.org/en/latest/) explains language and hardware APIs; the exact modules available can vary by firmware build.

### GPIO pins, digital input, and digital output

GPIO means **general-purpose input/output**. A pin can read a digital signal or drive a digital output, subject to the board’s electrical limits.

```python
from machine import Pin

output_pin = Pin(15, Pin.OUT)
output_pin.value(1)

input_pin = Pin(14, Pin.IN, Pin.PULL_UP)
print(input_pin.value())
``

Before connecting components, consult the official [Pico pinout and hardware documentation](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html). Pin numbers in code refer to GPIO numbers, which are not always the same as physical header-pin numbers.

### PWM, ADC, I²C, SPI, and UART

| Interface | What it does | Common project use |
|---|---|---|
| **PWM** | Varies a digital output’s duty cycle | LED brightness, compatible servo control |
| **ADC** | Reads analog voltage within supported limits | Potentiometers and analog sensors |
| **I²C** | Connects multiple devices over two shared signal lines | Sensor modules and small displays |
| **SPI** | Provides a synchronous serial connection | Displays, storage, and fast peripherals |
| **UART** | Sends and receives serial data | GPS modules, serial consoles, and device links |

Pico offers these hardware capabilities, but **software support and available pins depend on the board and firmware**. For a project with several sensors, sketch the pin assignments before wiring. That small pause can save a lot of cable archaeology.

### Files, modules, and external libraries

MicroPython’s filesystem can store scripts on the Pico. You can keep a startup file such as `main.py` and add other modules that your main program imports.

Some libraries are built into the firmware; others must be copied to the board or installed using a compatible tool. Check the library’s documentation for:

- MicroPython support (rather than CPython-only support).
- Compatibility with your firmware version.
- Compatibility with your Pico model.
- Required hardware interfaces and pin assignments.

A package being listed on [PyPI](https://pypi.org/) does **not** guarantee it will run on MicroPython. Many desktop packages rely on features, dependencies, or memory that a microcontroller does not have.

### Managing memory and limited resources

Pico is capable for embedded experiments, but it has less memory and storage than a desktop computer. Keep code and data compact, avoid unnecessary allocations in tight loops, and prefer small, focused libraries.

If a project grows beyond what is practical in MicroPython, that doesn’t mean the project has failed. It may mean you need a different design, a more efficient implementation, or another computing platform. Our [robotic simulations](https://roboticcoding.com/category/robotic-simulations/) resources can help you test control logic before moving to hardware.

## Using Python on Raspberry Pico W

Pico W can connect projects to Wi-Fi, which makes it useful for simple sensor reporting and networked experiments. Wireless support depends on the board, firmware, and MicroPython modules you install.

### Connect to Wi-Fi with MicroPython

A typical MicroPython Wi-Fi workflow uses the `network` module. Replace the sample network details with your own; avoid publishing credentials in code you share.

```python
import network
import time

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("YOUR_WIFI_NAME", "YOUR_WIFI_PASSWORD")

for _ in range(20):
 if wlan.isconnected():
 break
 time.sleep(1)

print(wlan.ifconfig() if wlan.isconnected() else "Connection failed")
``

Check the current [Raspberry Pi MicroPython documentation](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html) for the correct setup for your Pico W firmware. **Network code may need adjustments** when firmware APIs or wireless support change.

### Build a simple web server or IoT project

Once connected, Pico W can send readings to a local service or respond to simple network requests. A sensible first project is a temperature or light sensor that publishes a reading on your home network.

Keep expectations realistic:

- A microcontroller web server should remain small and simple.
- Wi-Fi projects depend on network availability and security.
- Don’t expose a hobby device directly to the public internet without understanding the risks.
- Consider whether a Raspberry Pi computer or hosted service is a better fit for long-running, multi-user applications.

For more connected and autonomous project ideas, explore our [artificial intelligence](https://roboticcoding.com/category/artificial-intelligence/) and [robotic sensors](https://roboticcoding.com/category/robotic-sensors/) categories.

## Raspberry Pico 2 and RP2350 Python Support

Pico 2 uses the RP2350 family rather than the RP2040 found in the original Pico. Python development is possible, but firmware and library support should be verified for the specific board.

### Firmware and editor compatibility

Before installing MicroPython on Pico 2:

1. Find the matching build on the [MicroPython downloads page](https://micropython.org/download/).
2. Confirm that the build names **Pico 2** or the exact board variant.
3. Install it using BOTSEL mode as described above.
4. Update your editor if it does not recognize the device.
5. Test a short GPIO example before connecting project hardware.

A newer chip does not guarantee every existing library will work unchanged. Check library documentation and board support before committing to a project.

### Moving projects from Pico to Pico 2

Most basic Python ideas—variables, loops, functions, and simple GPIO logic—transfer naturally. Hardware details can differ:

- The onboard LED implementation may differ by board.
- Wireless modules and pin assignments depend on the model.
- Firmware and peripheral support can change across chip generations.
- A library may target RP2040-specific features.

Port the project in small steps: first get a basic script running, then add the hardware interface, then test each external device.

## MicroPython vs. CircuitPython: Which Should You Use?

There’s no universal winner. Choose based on your board, the libraries your project needs, and how you prefer to learn.

### Ease of use, libraries, and board support

| Consideration | MicroPython | CircuitPython |
|---|---|---|
| **Raspberry Pi documentation** | Raspberry Pi’s Pico guides focus on MicroPython | Check CircuitPython’s board-specific guides |
| **Hardware ecosystem** | Broad microcontroller use and direct hardware APIs | Strong Adafruit learning material and library ecosystem |
| **Project portability** | Code may need changes across boards | Board support and library availability vary |
| **Beginer experience** | Thony offers an approachable setup | Often emphasizes approachable workflows and libraries |

If you’re following a Raspberry Pi tutorial, start with **MicroPython** so the instructions match. If your project depends on an Adafruit library or guide, check whether CircuitPython supports your board and required hardware.

### Can you install full CPython on a Pico?

For practical purposes, **don’t plan on running desktop CPython on a Pico**. Pico is a microcontroller board, not a general-purpose computer with a full operating system.

MicroPython provides familiar Python syntax in a form suitable for the board. If your application needs desktop packages, a filesystem-heavy workflow, or a full operating system, consider a Raspberry Pi computer instead.

## Troubleshooting Pico Python Setup and USB Errors

Most setup issues are caused by a cable, firmware mismatch, or editor configuration—not a mysterious defect in the board. Work through the checks in order.

### Pico does not appear as a USB drive or serial port

Try these checks:

1. Confirm you’re using a **USB data cable**, not a charge-only cable.
2. Hold **BOOTSEL** while connecting the board.
3. Try another USB port.
4. Disconnect other serial devices that might confuse the editor.
5. Check whether your operating system reports a newly connected USB device.

In BOTSEL mode, Pico should appear as a storage device for firmware installation. Once firmware is installed and the board restarts, it may instead appear as a serial device. Those are different modes, so the drive disappearing after a successful installation is normal.

### Thony cannot connect to the MicroPython device

- Select the correct MicroPython interpreter in Thony.
- Reconnect the Pico and wait for the serial device to appear.
- Close other programs that may be using the same serial port.
- Update Thony from its [official site](https://thony.org/).
- Reinstall the correct firmware if the board is not running MicroPython.

If you see a prompt in Thony’s Shell, test `print("hello")`. If the prompt is missing, focus on the USB connection and interpreter before debugging your program.

### Firmware download or installation fails

Verify that you downloaded the UF2 for the **exact Pico model**. Enter BOTSEL mode again and copy the file to the board’s `RPI-RP2` drive. Use official downloads from [MicroPython](https://micropython.org/download/) or the [Raspberry Pi documentation](https://www.raspberrypi.com/documentation/microcontrollers/micropython.html).

If a transfer appears to fail:

- Re-download the firmware.
- Try a different cable or port.
- Check that the file is a `.uf2` intended for your board.
- Avoid unpluging the board during the file copy.

### Fix common Python code and hardware errors

| Symptom | Likely cause | What to check |
|---|---|---|
| `ImportError` | Module is unavailable in this firmware | Confirm the module is supported and installed. |
| LED example does nothing | Wrong LED identifier or board-specific code | Use a board-appropriate example and firmware. |
| Sensor returns unexpected values | Wiring, pin selection, or voltage mismatch | Check the pinout and sensor datasheet. |
| Program stops responding | Infinite loop, blocked operation, or error | Use the REPL, reset the board, and inspect the traceback. |
| Wi-Fi fails to connect | Wrong credentials, signal, or firmware support | Verify network details and Pico W firmware compatibility. |

For electrical problems, stop and check the wiring before repeatedly rerunning code. A software typo is inconvenient; a voltage mistake can damage hardware.

## Safe Wiring and Reliable Pico Python Projects

A reliable project starts with safe connections and a backup plan. Read the [Raspberry Pi hardware documentation](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html) and the datasheet for each component you connect.

### GPIO voltage limits and power precautions

Pico GPIO uses **3.3 V logic**. Do not assume a 5 V sensor output is safe to connect directly. Use a suitable level shifter or interface circuit when required.

Also:

- Don’t drive motors directly from GPIO pins.
- Use an appropriate motor driver and power supply.
- Check component polarity and current requirements.
- Disconnect power before changing wiring.
- Confirm GPIO numbers against the board pinout, not just the physical header position.

For moving robots, motor noise and current draw can cause resets or unstable sensor readings. Separate power considerations from signal wiring, and follow the motor-driver manufacturer’s instructions.

### Back up code and update firmware safely

Keep project files on your computer or in version control, especially before replacing firmware or experimenting with startup scripts. Save a known-good copy before changing wiring or libraries.

A practical maintenance habit:

1. Keep a working backup of `main.py` and supporting modules.
2. Record the board model and firmware version.
3. Test changes with simple scripts before combining them.
4. Update firmware only when you need a fix, feature, or board support improvement.
5. Retest project hardware after an update.

That little notebook entry—board, firmware, and what changed—can turn future troubleshooting from guesswork into an actual engineering process.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.