Registry / devops / rpi-gpio

rpi-gpio

JSON →
library0.7.1pypypiunverified

A module to control Raspberry Pi GPIO channels. Provides a simple interface for digital input/output, PWM, and interrupt handling on the Raspberry Pi. Latest version 0.7.1; no longer actively maintained since the BCM2835 GPIO driver update. Works on all Raspberry Pi models but requires root. Uses BCM (Broadcom) pin numbering by default.

sudo pip install RPi.GPIO
INSTALL
IMPORT
SIG · RPI-GPIO
R
rpi-gpio
devopspythonv0.7.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RPi.GPIO as GPIO
import RPi.GPIO as GPIO
import rpi_gpio as GPIO
case-sensitive, hyphen turns to dot
GPIO
import RPi.GPIO as GPIO
from RPi import GPIO
GPIO is not a submodule of RPi

Blink an LED on BCM pin 18 using BCM numbering.

import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) while True: GPIO.output(18, GPIO.HIGH) time.sleep(1) GPIO.output(18, GPIO.LOW) time.sleep(1)
Debug
Known issues
gotchaMust run with root (sudo) or as root user. Otherwise RuntimeError: No access to /dev/mem.
fix
Run script with `sudo python script.py`.
affects: all
deprecatedRPi.GPIO is no longer actively maintained and may not support newer kernels or Pi 5. Consider using gpiozero, lgpio, or rpi-lgpio.
fix
Switch to gpiozero (high-level) or lgpio (low-level).
affects: 0.7.x
gotchaGPIO.setwarnings(False) is required to suppress warnings about channel already in use when not cleaning up.
fix
Add GPIO.setwarnings(False) after import and before any setup calls.
affects: all
gotchaAfter using GPIO, call GPIO.cleanup() to release pins. Failure can leave pins in unexpected states and cause issues on subsequent runs.
fix
Use try/finally or atexit to ensure GPIO.cleanup() is called.
affects: all
Errors
Common errors & fixes
RuntimeError: No access to /dev/mem. Try running as root!
Script executed without root privileges.
fix
Run the script with sudo: sudo python your_script.py
RuntimeError: This module can only be run on a Raspberry Pi!
Attempt to import RPi.GPIO on a non-Raspberry Pi system.
fix
Check platform before import: if platform.machine() not in ('armv7l', 'aarch64'): print('Not a Pi')
ImportError: No module named RPi.GPIO
RPi.GPIO not installed or not found (e.g., virtual environment without --system-site-packages).
fix
Install with: sudo pip install RPi.GPIO
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Called GPIO.setup or GPIO.output before calling GPIO.setmode.
fix
Add GPIO.setmode(GPIO.BCM) (or GPIO.BOARD) before any other GPIO calls.
Upgrade
Version history
0.7.1latest on PyPI · released Feb 6, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
rpi-gpio — pip install rpi-gpio · libregistry