If you’ve just setup your shiny new Raspberry Pi 2 and tried to run a Python script that accesses GPIO you might be sad to see an error like this:
Traceback (most recent call last):
File “”, line 1, in
RuntimeError: This module can only be run on a Raspberry Pi!
Don’t worry! The version of the RPi.GPIO Python library shipped with the latest Raspbian OS doesn’t support the Pi 2 out of the box, but you can install a later version to fix the problem.
First check what version of the RPi.GPIO library is currently available from Python’s package index here. Version 0.5.9 and below unfortunately are not compatible with the Pi 2, however version 0.5.10 and above should work.
If you see version 0.5.10 or greater on the site then you can install it with a few simple commands. First connect to your Pi 2 in an SSH / terminal session (check out this guide if you’re new to Linux & the Pi 2, or try the awesome new Pi Finder to get a terminal open e