rpi.gpio originally referred to a Python library RPi.GPIO for accessing the Raspberry Pi's GPIO pins. This was included in Raspberry Pi OS prior to Bullseye and runs on all Pi models up to Pi4. It is not supported on Pi5. There is now a module python3-rpi-lgpio (which is compatibility shim for lgpio emulating the RPi.GPIO API) which also creates a library RPi.GPIO The module allows GPIO pins to be initialised, turned on, and turned off.
You can install the original RPi.GPIO on all Pi models before 2812 SoC (used on Pi5).
apt install python3-rpi.gpio
This was automatically installed by default in Raspberry Pi OS prior to Bullseye.
For more information see the rpio.gpio homepage.
You can install the compatibility shim on recent Raspberry Pi OS.
apt install rpi-lgpio
It is installed by default on Trixie.
See https://rpi-lgpio.readthedocs.io/en/latest/api.html
This does have some limitations; See https://rpi-lgpio.readthedocs.io/en/latest/differences.html
Warning You cannot install rpi-lgpio and rpi-gpio (aka RPi.GPIO, the library it emulates) at the same time, in the same Python environment. Both packages attempt to install a module named RPi.GPIO and obviously this will not work.
Please Note!
If you are not aware, there are a number of different pieces of software that serve a similar fundamental purpose (controlling the Raspberry Pi GPIO pins) and are independent of one another. Not surprisingly, they also all use spins on combining "rpi" and "gpio" in their name. Each has a separate tag and questions about their use should use that specific tag. This is documented here to prevent confusion.
- The page you are on now is for the
RPi.GPIOmodule for python: Tag rpi.gpio - The
pigpiolibrary, written in C but with ports to python and other languages: Tag pigpio - The
pi-gpiolibrary, for node.js (javascript): Tag pi-gpio
This isn't intented as an exhaustive list of such software, just the three most prone to confusion here due to the similar names perhaps made more similiar by restrictions on tag labels (all lower case, etc).