libpci

raw JSON →
0.2 verified Fri May 01 auth: no python maintenance

Pure-Python, high-level bindings to libpci, providing access to PCI device information. Current version 0.2, low release cadence (last release 2016). Actively maintained? Possibly minimal.

pip install libpci
error ImportError: libpci.so.3: cannot open shared object file: No such file or directory
cause System library libpci not installed or not found.
fix
Install libpci3 or libpci-dev package (e.g., sudo apt install libpci-dev).
error PermissionError: [Errno 13] Permission denied: '/sys/bus/pci/devices/...'
cause Non-root user cannot read PCI device files.
fix
Run script with sudo: sudo python script.py
error AttributeError: module 'pci' has no attribute 'PCIDevices'
cause Old version or incorrect installation; PCIDevices is class in pci module.
fix
Verify installation: pip install --upgrade libpci
gotcha libpci requires libpci (or libpci-dev) system library installed. On Debian/Ubuntu: sudo apt install libpci-dev. Otherwise ImportError about missing shared library.
fix Install system package: sudo apt-get install libpci-dev
gotcha Initialization might require root privileges to read PCI config space. Use 'pci.PCIDevices()' may fail with PermissionError if /sys/bus/pci/devices is read-only for non-root.
fix Run script as root or use sudo.
deprecated libpci 0.2 is last release; no updates since 2016. Consider using 'pypci' for more modern API.
fix Switch to pypci: pip install pypci

List all PCI devices with vendor and device names.

import pci

# Enumerate all PCI devices
devices = pci.PCIDevices()
for dev in devices:
    print(dev.address, dev.vendor_name, dev.device_name)