skillfed

gpiozero

A simple interface to GPIO devices with Raspberry Pi

gpiozero v2.0.1.post3 435.4K downloads/30d#6,682 on PyPI2,133
Permissive license BSD-3-Clause Active released

What it is and what it does

gpiozero is a Python library that simplifies GPIO programming on Raspberry Pi and compatible single-board computers. It provides object-oriented interfaces to common components—LEDs, buttons, sensors, motors—so you can control hardware with just a few lines of code rather than managing raw GPIO pins. The library supports both imperative (direct method calls) and declarative (event-driven) programming styles, and includes a mock pin interface for testing without hardware.

The package abstracts away the complexity of underlying pin libraries, letting you switch between different GPIO backends (RPi.GPIO, pigpio, etc.) without changing your application code. It's designed for physical computing education and hobbyist projects, but scales to more complex setups through its source/values system for composing sensor inputs and device behaviors.

Use it for:

  • Control an LED or relay directly: turn it on/off or blink it with minimal code.
  • Build event-driven circuits: trigger actions when a button is pressed or a sensor detects motion.
  • Combine multiple sensors to control an output: e.g., turn on a garden light only when motion is detected AND it's dark.
  • Prototype robotics or automation projects without writing low-level GPIO boilerplate.
  • Test GPIO logic on a PC using mock pins before deploying to a Raspberry Pi.
  • Teach physical computing concepts with readable, beginner-friendly Python syntax.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

gpiozero provides a high-level Python interface for controlling GPIO devices on Raspberry Pi and compatible boards, abstracting away low-level pin manipulation with simple, declarative component classes.

Yes. gpiozero is the standard choice for Raspberry Pi GPIO programming in Python—actively maintained, permissively licensed, low friction to install, and well-documented. It's suitable for beginners learning physical computing and for production hobby/educational projects. Install it if you're working with Raspberry Pi GPIO devices and want to avoid raw pin manipulation.

Install

gpiozero on PyPI

pip

pip install gpiozero

uv

uv add gpiozero

poetry

poetry add gpiozero

Installing gpiozero

Before you install

Low install friction with only three lightweight runtime dependencies (colorzero, importlib-metadata, importlib-resources). Actively maintained with a recent release 18 days ago and consistent commit activity; supports current Python versions (3.9–3.12 and PyPy).

License in practice

BSD-3-Clause (permissive) allows free use, modification, and distribution with minimal restrictions, making it suitable for both personal and commercial projects.

Quickstart

pip install gpiozero

from gpiozero import LED
from time import sleep

led = LED(17)
led.on()
sleep(1)
led.off()

Requires a Raspberry Pi or compatible board with GPIO pins, or mock pins for testing on other systems.

Verify before relying

  • Whether the package works reliably on all advertised Python implementations (PyPy support level).
  • Performance characteristics when controlling many devices simultaneously.
  • Compatibility with non-Raspberry Pi GPIO boards beyond what the documentation states.

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 3 — colorzero, importlib-metadata, importlib-resources
Maintenance actively maintained — 18 days since the last release
Last repo commit
First released
Downloads 435,360/month — #6,682 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: gpiozero-2.0.1.post3-py3-none-any.whl

Keywords: raspberrypi, gpio

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: EducationProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: EducationTopic :: System :: Hardware

Tags

raspberry pi gpio controlpython led button sensorgpio device interfaceraspberry pi physical computingsimple gpio librarypi hardware abstractioncomponent-based gpio
raspberry-pihardware-controliot

More Education packages