{"id":22396,"library":"spidev","title":"spidev","description":"Python bindings for Linux SPI access through spidev. Current version 3.8 provides low-level control of SPI devices via the Linux spidev kernel interface. Release cadence is infrequent; maintained on GitHub.","status":"active","version":"3.8","language":"python","source_language":"en","source_url":"http://github.com/doceme/py-spidev","tags":["spi","linux","embedded","hardware","spidev"],"install":[{"cmd":"pip install spidev","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"System-level dependency: Linux spidev kernel module must be loaded (e.g., 'modprobe spidev')","package":"spidev","optional":false}],"imports":[{"note":"Common mistake: 'import spidev' only gives access to the module object, not the SpiDev class. Use 'from spidev import SpiDev' for direct access.","wrong":"import spidev","symbol":"SpiDev","correct":"from spidev import SpiDev"}],"quickstart":{"code":"from spidev import SpiDev\n\nspi = SpiDev()\nspi.open(0, 0)  # bus=0, device=0\nspi.max_speed_hz = 1000000\nspi.mode = 0b00\n\nto_send = [0x01, 0x02, 0x03]\nresponse = spi.xfer(to_send)\nprint(response)\nspi.close()","lang":"python","description":"Open SPI bus 0, device 0, transfer bytes, and close."},"warnings":[{"fix":"Set 'spi.bits_per_word = 8' explicitly, or check device datasheet before changing.","message":"Bits per word default is 8. Changing to other values (e.g., 16) may cause unexpected transfer behavior unless hardware supports it.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'spi.open_path(\"/dev/spidev0.0\")' for dynamic bus numbering, or stick with 'spi.open(bus, device)' for static.","message":"In v3.8, the 'open_path' method was added. Older code using only 'open(bus, device)' still works, but dynamic bus allocation may require file path-based opening.","severity":"breaking","affected_versions":">=3.8"},{"fix":"Replace 'spi.xfer2' with 'spi.xfer'.","message":"Using 'spi.xfer2' is deprecated in favor of 'spi.xfer'. xfer2 was a non-standard name and may be removed in future versions.","severity":"deprecated","affected_versions":"all"},{"fix":"Run as root, or add a udev rule to set permissions on /dev/spidev* (e.g., 'SUBSYSTEM==\"spidev\", MODE=\"0666\"').","message":"Running without root or proper permissions (e.g., no udev rule) yields 'PermissionError' or 'OSError: [Errno 13] Permission denied'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Load the spidev module: 'sudo modprobe spidev' and check /dev for spidev files (e.g., ls /dev/spi*).","cause":"SPI device node does not exist; kernel module not loaded or incorrect bus/device number.","error":"OSError: [Errno 2] No such file or directory"},{"fix":"Run as root or add a udev rule to grant permissions (e.g., 'SUBSYSTEM==\"spidev\", MODE=\"0666\"').","cause":"User lacks read/write access to /dev/spidev*.","error":"PermissionError: [Errno 13] Permission denied"},{"fix":"Use 'from spidev import SpiDev' to import the class.","cause":"Incorrect import: using 'import spidev' instead of 'from spidev import SpiDev'.","error":"AttributeError: module 'spidev' has no attribute 'SpiDev'"},{"fix":"Use 'spi.open_path(\"/dev/spidev0.0\")' instead of 'spi.open_path(bus, device)'.","cause":"Wrong number of arguments when calling 'open_path' — expects a single path string.","error":"TypeError: function takes at most 2 arguments (3 given)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}