By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,088 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,088 IT Pros & Developers. It's quick & easy.

Python.h No such file...

P: n/a
When I add #include <Python.h> to a
header file, GCC tells me, No such file or directory.

Am trying to learn how to combine C++ and Python.
Using SuSE 9.0 Linux, 2.4.21-231-default
GCC 3.3.1
Python 2.3.4 (Just built on the box successfully)

My problem is is probably because I am
ignorant of correct GCC setup and config for Python.
I am using the default SuSE GCC setup unchanged.

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

I have hunted through the info docs, particularly GCC, but cannot see
where I change the config to fix this...?

Tried specifying the full path, #include ".../Python.h"
but then lots of related stuff breaks cos its not found...

The compile is a simple/test exercise
and works without the Python.h header line.

Posted this first to the comp.lang.C++ newsgroup, cos it looks like a
GCC item, but no joy.

Appreciate any suggestions or hints as to what to look for.

Steve Doody.
SD AT ACM DOT ORG

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Steve> When I add #include <Python.h> to a
Steve> header file, GCC tells me, No such file or directory.

Steve> Am trying to learn how to combine C++ and Python.
Steve> Using SuSE 9.0 Linux, 2.4.21-231-default
Steve> GCC 3.3.1
Steve> Python 2.3.4 (Just built on the box successfully)

Make sure you have the relevant -devel package installed from your
installation media.

Skip
Jul 18 '05 #2

P: n/a
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.

HTH!

Heiko.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.