I am trying to compile a Python extension written in C on a CentOS machine. I am getting
error: Python.h: No such file or directory
It works fine on ubuntu, where I have python-dev installed using apt-get.
I tried installing python-devel using
yum install python-devel
but it is already installed. How do I fix this error?
On my system the Python.h
header file is in the path /usr/include/python2.6/
. As this path is not searched by the pre-processor by default, you have to add it to the list of paths to search. This is done with the -I
option to the compiler, like this:
$ gcc -I/usr/include/python2.6 source.c -o program
Change the path above to the actual path on your system. You can find it either with the find
command as proposed in a comment, of with the locate
command if it's installed.