{"id":28192,"library":"smbus","title":"smbus - Python SMBus bindings","description":"Python bindings for Linux SMBus access through i2c-dev. Current version 1.1.post2. Minimal maintenance, not actively developed.","status":"maintenance","version":"1.1.post2","language":"python","source_language":"en","source_url":"https://github.com/bivab/smbus-cffi","tags":["smbus","i2c","raspberry-pi","linux"],"install":[{"cmd":"pip install smbus","lang":"bash","label":"Install smbus"}],"dependencies":[],"imports":[{"note":"Direct import is preferred but old style still works. However, using from smbus import SMBus is more explicit.","wrong":"import smbus; bus = smbus.SMBus(1)","symbol":"SMBus","correct":"from smbus import SMBus"}],"quickstart":{"code":"from smbus import SMBus\n\nbus = SMBus(1)  # /dev/i2c-1\naddress = 0x48\ndata = bus.read_byte_data(address, 0x00)\nprint(f\"Read: {data}\")\nbus.close()","lang":"python","description":"Open I2C bus 1, read one byte from register 0x00 of device at address 0x48."},"warnings":[{"fix":"Run script with sudo or add user to i2c group: sudo usermod -aG i2c $USER","message":"smbus requires root/sudo access to /dev/i2c-* devices. Running without privileges causes PermissionError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use smbus >=1.1 for Python 3 support, or install smbus-cffi as alternative.","message":"smbus is Python 2 only in older versions; version 1.1.post2 supports Python 3 but check system Python version.","severity":"gotcha","affected_versions":"<1.1"},{"fix":"Replace import with smbus2 (from smbus2 import SMBus) for nearly identical API.","message":"smbus package is largely unmaintained; consider migrating to smbus2 or smbus-cffi for active support and Python 3 compatibility.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"pip install smbus","cause":"smbus package not installed.","error":"ModuleNotFoundError: No module named 'smbus'"},{"fix":"Run script with sudo or add user to i2c group.","cause":"User does not have access to I2C bus.","error":"PermissionError: [Errno 13] Permission denied: '/dev/i2c-1'"},{"fix":"Enable I2C via raspi-config or check bus number with i2cdetect -l.","cause":"I2C device not enabled or incorrect bus number.","error":"FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}