skillfed

gpiod

Python bindings for libgpiod

gpiod v2.5.0 643.4K downloads/30d#5,607 on PyPI438
Copyleft license LGPL-2.1-or-later Active released

What it is and what it does

gpiod is the official Python interface to libgpiod, the modern Linux kernel GPIO character device API. It replaces the deprecated sysfs interface with a more capable, resource-safe approach that guarantees cleanup on device close. The package vendors libgpiod for convenience, so you don't need a matching system library unless you explicitly opt in via LINK_SYSTEM_LIBGPIOD=1.

You use it to request GPIO lines from character devices like /dev/gpiochip0, configure them as inputs or outputs, read or write values, and poll for events. It supports advanced features like open-source and open-drain modes, bulk value operations, and event monitoring. The bindings are not thread-safe and require external synchronization if shared across threads, though both GIL-enabled and free-threaded CPython are supported.

Use it for:

  • Control LEDs, buttons, and sensors on Raspberry Pi or other Linux single-board computers.
  • Implement GPIO-based hardware monitoring or automation in embedded systems.
  • Poll GPIO lines for state changes and react to hardware events in real time.
  • Configure open-drain or open-source GPIO modes for multi-device bus protocols.
  • Build device drivers or system utilities that interact with GPIO character devices.

Worth the install?

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

Python bindings for libgpiod, the official Linux GPIO character device interface library, enabling control of GPIO lines with support for event polling, multi-value operations, and open-source/open-drain modes.

Yes, if you need to control GPIO on Linux. It is the official, actively maintained binding to the modern kernel interface, supports current Python versions (3.10–3.14), has no known vulnerabilities, and provides binary wheels for common platforms. The copyleft license is standard for GPIO libraries and acceptable in most open-source contexts. Install friction is moderate but manageable with python3-dev.

Install

gpiod on PyPI

pip

pip install gpiod

uv

uv add gpiod

poetry

poetry add gpiod

Installing gpiod

Before you install

Medium install friction due to binary wheel availability for common platforms (Python 3.10–3.14 on x86_64 and aarch64 Linux) but source builds require python3-dev. Active maintenance with recent release (58 days ago) and ongoing repository activity.

License in practice

LGPL-2.1-or-later copyleft license requires derivative works and linked applications to disclose source code under compatible terms; acceptable for open-source projects but may constrain proprietary deployments.

Quickstart

pip install gpiod

import gpiod
from gpiod.line import Direction, Value

with gpiod.request_lines(
    "/dev/gpiochip0",
    consumer="example",
    config={0: gpiod.LineSettings(direction=Direction.OUTPUT)}
) as request:
    request.set_value(0, Value.ACTIVE)

Requires python3-dev; source builds need libgpiod headers. Binary wheels available for Python 3.10–3.14 on Linux x86_64 and aarch64. Root access needed to interact with /dev/gpiochip* devices.

Verify before relying

  • Whether free-threaded CPython support (mentioned in description) is production-ready or experimental.
  • Performance characteristics and latency guarantees for GPIO event polling under load.
  • Compatibility with non-Linux POSIX systems or Windows via WSL.
  • Whether vendored libgpiod can be overridden with system package via LINK_SYSTEM_LIBGPIOD=1.

Package facts

License LGPL-2.1-or-later (copyleft)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 58 days since the last release
Last repo commit
First released
Downloads 643,433/month — #5,607 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: gpiod-2.5.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; gpiod-2.5.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; gpiod-2.5.0-cp310-cp310-musllinux_1_2_aarch64.whl; gpiod-2.5.0-cp310-cp310-musllinux_1_2_x86_64.whl; gpiod-2.5.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; gpiod-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; gpiod-2.5.0-cp311-cp311-musllinux_1_2_aarch64.whl; gpiod-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl; gpiod-2.5.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; gpiod-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; gpiod-2.5.0-cp312-cp312-musllinux_1_2_aarch64.whl; gpiod-2.5.0-cp312-cp312-musllinux_1_2_x86_64.whl; gpiod-2.5.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; gpiod-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; gpiod-2.5.0-cp313-cp313-musllinux_1_2_aarch64.whl; gpiod-2.5.0-cp313-cp313-musllinux_1_2_x86_64.whl; gpiod-2.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; gpiod-2.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; gpiod-2.5.0-cp314-cp314-musllinux_1_2_aarch64.whl; gpiod-2.5.0-cp314-cp314-musllinux_1_2_x86_64.whl

Development Status :: 5 - Production/StableOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Free Threading :: 3 - StableTyping :: Typed

Tags

GPIO control Linux Pythonlibgpiod Python bindingsGPIO character device interfaceRaspberry Pi GPIO libraryLinux GPIO line controlGPIO event pollingembedded GPIO management
gpio-controlembedded-systemslinux-hardware

More Software Development packages