Tested on:Raspberry Pi 2; Raspberry Pi B+; Raspbian pre Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)

Raspberry Pi: Installation of the Serial Peripheral Interface Bus SPI

The Serial Peripheral Interface Bus is a synchronous(timed) bus which can act like an shift register and therefore multiply the input or output channels of the Raspberry Pi’s GPIO. Additionally, SPI allows very fast data transfer!

To install the SPI module for python, type in the terminal

In raspi-config, goto Advanced Options, then to A6 SPI and confirm. Confirm when asked to load SPI at bootup, too, and reboot afterwards.

After the reboot, start python with sudo python and try to import the spidev library:

Python 3
For installing spidev for Python 3, just replace the line


in this tutorial.

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. Is there a difference between spidev (3.2) and the library ‘python-periphery’, or the ‘py-libbcm2835’ library? They all seem to do spi, however not sure if they have different applications or if they are just deprecated libraries?

    Interestingly, the spidev documentation says you can set the number of bits per word(transfer) , 8..16, however according to the pi documentation, the spi peripheral connected to the header only supports 8/9! So perhaps spidev is a generic driver whose functionality may or may not be fully supported by the rpi?

    • Hi,
      i don’t know python-periphery so far, but it sounds interesting. python-periphery supports not only SPI, but other interfaces. It probably uses spidev internally. py-libbcm2835 are Python C bindings and might be a prerequisite for running SPI.


Time limit is exhausted. Please reload CAPTCHA.