{"id":23161,"library":"rpi-gpio","title":"RPi.GPIO","description":"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.","status":"maintenance","version":"0.7.1","language":"python","source_language":"en","source_url":"https://sourceforge.net/projects/raspberry-gpio-python/","tags":["raspberry-pi","gpio","iot","embedded"],"install":[{"cmd":"sudo pip install RPi.GPIO","lang":"bash","label":"Standard install with root"}],"dependencies":[],"imports":[{"note":"case-sensitive, hyphen turns to dot","wrong":"import rpi_gpio as GPIO","symbol":"RPi.GPIO as GPIO","correct":"import RPi.GPIO as GPIO"},{"note":"GPIO is not a submodule of RPi","wrong":"from RPi import GPIO","symbol":"GPIO","correct":"import RPi.GPIO as GPIO"}],"quickstart":{"code":"import RPi.GPIO as GPIO\nimport time\n\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(18, GPIO.OUT)\n\nwhile True:\n    GPIO.output(18, GPIO.HIGH)\n    time.sleep(1)\n    GPIO.output(18, GPIO.LOW)\n    time.sleep(1)","lang":"python","description":"Blink an LED on BCM pin 18 using BCM numbering."},"warnings":[{"fix":"Run script with `sudo python script.py`.","message":"Must run with root (sudo) or as root user. Otherwise RuntimeError: No access to /dev/mem.","severity":"gotcha","affected_versions":"all"},{"fix":"Switch to gpiozero (high-level) or lgpio (low-level).","message":"RPi.GPIO is no longer actively maintained and may not support newer kernels or Pi 5. Consider using gpiozero, lgpio, or rpi-lgpio.","severity":"deprecated","affected_versions":"0.7.x"},{"fix":"Add GPIO.setwarnings(False) after import and before any setup calls.","message":"GPIO.setwarnings(False) is required to suppress warnings about channel already in use when not cleaning up.","severity":"gotcha","affected_versions":"all"},{"fix":"Use try/finally or atexit to ensure GPIO.cleanup() is called.","message":"After using GPIO, call GPIO.cleanup() to release pins. Failure can leave pins in unexpected states and cause issues on subsequent runs.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run the script with sudo: sudo python your_script.py","cause":"Script executed without root privileges.","error":"RuntimeError: No access to /dev/mem.  Try running as root!"},{"fix":"Check platform before import: if platform.machine() not in ('armv7l', 'aarch64'): print('Not a Pi')","cause":"Attempt to import RPi.GPIO on a non-Raspberry Pi system.","error":"RuntimeError: This module can only be run on a Raspberry Pi!"},{"fix":"Install with: sudo pip install RPi.GPIO","cause":"RPi.GPIO not installed or not found (e.g., virtual environment without --system-site-packages).","error":"ImportError: No module named RPi.GPIO"},{"fix":"Add GPIO.setmode(GPIO.BCM) (or GPIO.BOARD) before any other GPIO calls.","cause":"Called GPIO.setup or GPIO.output before calling GPIO.setmode.","error":"RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}