fatal error: Python.h: No such file or directory

root@raspberrypi ~/tools/RPi.GPIO-0.5.2a # python setup.py install
running install
Checking .pth file support in /usr/local/lib/python2.7/dist-packages/
/usr/bin/python -E -c pass
TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing RPi.GPIO.egg-info/PKG-INFO
writing top-level names to RPi.GPIO.egg-info/top_level.txt
writing dependency_links to RPi.GPIO.egg-info/dependency_links.txt
reading manifest file 'RPi.GPIO.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'RPi.GPIO.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv6l/egg
running install_lib
running build_py
running build_ext
building 'RPi.GPIO' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -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
compilation terminated.
error: command 'gcc' failed with exit status 1

解决方法:

安装对应版本的 python-dev,

root@raspberrypi ~/tools/RPi.GPIO-0.5.2a # apt-get install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  python2.7-dev
0 upgraded, 1 newly installed, 0 to remove and 343 not upgraded.
Need to get 28.7 MB of archives.
After this operation, 35.3 MB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python2.7-dev armhf 2.7.3-6 [28.7 MB]
Fetched 28.7 MB in 17s (1,644 kB/s)
Selecting previously unselected package python2.7-dev.
(Reading database ... 66907 files and directories currently installed.)
Unpacking python2.7-dev (from .../python2.7-dev_2.7.3-6_armhf.deb) ...
Processing triggers for man-db ...
Setting up python2.7-dev (2.7.3-6) ...

 

error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)

安装 Django 时遇到如下的提示:
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
安装所适应的 python-dev 或 python-devel 可以解决这个问题。

The following error was shown while I was installing Django.
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
Installing your distribution's python-dev or python-devel package may solve this problem.