Python.h No such file...

Heiko Wundram heikowu at
Tue Jul 27 04:29:59 CEST 2004

Am Dienstag, 27. Juli 2004 03:41 schrieb Steve Doody:
> When I add #include <Python.h> to a
> header file, GCC tells me, No such file or directory.

Well you're trying to include a global header called Python.h using this 
format. Now, gcc never looks for global headers in directories other 
than /usr/include and /usr/local/include per default, that's why you're 
seeing "No such file or directory".

> I installed Python from source to /usr/local/Python-2.3.4/
> The Include directory, and everything else, is there.

Does this mean you set --prefix to /usr/local/Python-2.3.4/ on configure? If 
yes, try specifying -I/usr/local/Python-2.3.4/include/python2.3 on the gcc 
line, and it'll start looking for global headers in that directory (which 
should contain Python.h).

If you just took the default route of installing it to /usr/local/, add 
-I/usr/local/include/python-2.3 to the gcc line.

If you installed Python to /usr/local/Python-2.3.4, gcc will not only not find 
the python includes, but will also not find the python libraries which are 
needed for linking. So, you'll also have to specify 
-L/usr/local/Python-2.3.4/lib on the gcc command line. This is not necessary 
if you installed it to /usr/local/

So, compiling your file should be done in the following way:

gcc -I/usr/local/Python-2.3.4/include/python2.3 \
    -L/usr/local/Python-2.3.4/lib -lpython -o test test.c

Or something of the like.



More information about the Python-list mailing list