unable to setup python GPIO for RaspberryPi

You might have encountered the following error when you tried to setup python GPIO for Pi:

source/py_gpio.c:23:20: fatal error: Python.h: No such file or directory

Or it looked like this:

[root@wheeljack RPi.GPIO-0.5.11]# python setup.py install
running install
running build
running build_py
creating build
creating build/lib.linux-armv6l-2.7
creating build/lib.linux-armv6l-2.7/RPi
copying RPi/__init__.py -> build/lib.linux-armv6l-2.7/RPi
running build_ext
building 'RPi.GPIO' extension
creating build/temp.linux-armv6l-2.7
creating build/temp.linux-armv6l-2.7/source
gcc -pthread -fno-strict-aliasing -O2 -g -march=armv6 -mfloat-abi=hard -mfpu=vfp -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -march=armv6 -mfloat-abi=hard -mfpu=vfp -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-armv6l-2.7/source/py_gpio.o
source/py_gpio.c:23:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
[root@wheeljack RPi.GPIO-0.5.11]#

The real problem is that you are missing the python development package. You can install it quite easy.
a) If you are using Debian/Ubuntu Linux
apt-get install python-dev
b) If you are using Fedora/CentOS/RedHat
yum install python-dev
c) If you are using Suse
zypper install python-dev

If this didn’t solved your problem please mentioned it in a commend and we will figure it out.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *