Adafruit PureIO provides pure Python (i.e., no native extensions) access to Linux IO, specifically for I2C and SPI buses. It serves as a drop-in replacement for the `smbus` and `spidev` modules, making it suitable for embedded systems like Raspberry Pi without requiring compilation. The library is actively maintained by Adafruit, with releases typically focusing on infrastructure updates, bug fixes, and compatibility improvements.
pip install adafruit-pureioVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize an I2C bus using `SMBus` and perform a basic byte read operation. It includes error handling for common issues like bus not found or permission denied. Remember to enable I2C via your system configuration (e.g., `raspi-config` on Raspberry Pi) and ensure the user running the script has appropriate permissions (e.g., belongs to the 'i2c' group).
Ensure the user running the Python script is part of the `i2c` and/or `spi` groups (e.g., `sudo usermod -aG i2c,spi $USER`) or run the script with `sudo`. Remember to log out and back in for group changes to take effect.
On Raspberry Pi, ensure I2C/SPI is enabled via `sudo raspi-config` under 'Interface Options'. For other Linux systems, consult documentation on enabling device tree overlays or kernel modules for your specific hardware.
Upgrade to `adafruit-pureio` version 1.1.7 or newer to ensure full compatibility with Python 3.9+ environments. `pip install --upgrade adafruit-pureio`.
Verify the I2C bus is enabled in your system's configuration (e.g., `sudo raspi-config` on Raspberry Pi). Check which bus IDs are available (e.g., by listing `/dev/i2c-*` or `/dev/spi*`).
Add the user to the appropriate group (e.g., `i2c`, `spi`) using `sudo usermod -aG i2c $USER` and reboot or log out/in. Alternatively, run the script with `sudo` (though this is generally less secure).
Ensure you have `adafruit-pureio` installed (`pip install adafruit-pureio`) and use the correct import statement: `from Adafruit_PureIO.smbus import SMBus`. If you intended to use the C-extension `smbus` library, install that instead (`pip install smbus-cffi` or similar).
No dependency data recorded yet.