Registry / devops / smbus
library1.1.post2pypypi✓ verified 84d ago

Python bindings for Linux SMBus access through i2c-dev. Current version 1.1.post2. Minimal maintenance, not actively developed.

pip install smbus
INSTALL
IMPORT
SIG · SMBUS
S
smbus
devopspythonv1.1.post2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SMBus
from smbus import SMBus
import smbus; bus = smbus.SMBus(1)
Direct import is preferred but old style still works. However, using from smbus import SMBus is more explicit.

Open I2C bus 1, read one byte from register 0x00 of device at address 0x48.

from smbus import SMBus bus = SMBus(1) # /dev/i2c-1 address = 0x48 data = bus.read_byte_data(address, 0x00) print(f"Read: {data}") bus.close()
Debug
Known issues
gotchasmbus requires root/sudo access to /dev/i2c-* devices. Running without privileges causes PermissionError.
fix
Run script with sudo or add user to i2c group: sudo usermod -aG i2c $USER
affects: all
gotchasmbus is Python 2 only in older versions; version 1.1.post2 supports Python 3 but check system Python version.
fix
Use smbus >=1.1 for Python 3 support, or install smbus-cffi as alternative.
affects: <1.1
deprecatedsmbus package is largely unmaintained; consider migrating to smbus2 or smbus-cffi for active support and Python 3 compatibility.
fix
Replace import with smbus2 (from smbus2 import SMBus) for nearly identical API.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'smbus'
smbus package not installed.
fix
pip install smbus
PermissionError: [Errno 13] Permission denied: '/dev/i2c-1'
User does not have access to I2C bus.
fix
Run script with sudo or add user to i2c group.
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
I2C device not enabled or incorrect bus number.
fix
Enable I2C via raspi-config or check bus number with i2cdetect -l.
Upgrade
Version history
1.1.post2latest on PyPI · released Mar 8, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
smbus — pip install smbus · libregistry