GPIO Zero is a Python library that provides a simple and approachable interface to GPIO (General Purpose Input/Output) devices on Raspberry Pi. It abstracts away low-level pin details, offering high-level classes for common components like LEDs, buttons, motors, and sensors, making physical computing accessible. The current version is 2.0.1. It generally follows a release cadence tied to bug fixes and new features, with major versions introducing breaking changes.
pip install gpiozeroVerified import paths — ran on the pinned version, not inferred.
This quickstart code demonstrates how to make an LED connected to GPIO pin 17 blink. The `pause()` function keeps the script running indefinitely, allowing the LED to continue blinking.
Migrate your code to Python 3.9 or newer. Ensure your environment uses Python 3.
Pass initialized `Motor` or `PhaseEnableMotor` objects to the `Robot` constructor. The old tuple-based method is deprecated and will be removed.
If your project relies on the previous default, explicitly set `GPIOZERO_PIN_FACTORY=rpigpio` as an environment variable or set it in your code using `gpiozero.Device.pin_factory = 'rpigpio'`.
Rename your script to anything other than `gpiozero.py` (e.g., `my_gpio_project.py`).
Always assign the function object, not its return value, to event handlers: `button.when_pressed = my_function`.
Rename your script file to something different, like `my_project.py` or `led_blink.py`.
Ensure all previous scripts using GPIO have terminated cleanly. You can also explicitly close devices with `device.close()`. If the issue persists, reboot your Raspberry Pi.
Use the correct event handler property, for example, `button.when_pressed = my_callback_function` to assign a function to be called when the button is pressed. If you intended to check the state, use `button.is_pressed`.
No dependency data recorded yet.