473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Python.h No such file...

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
2 4753

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: kartik | last post by:
2 enable non-backward compatible changes to be made to the language or the standard library (or other libraries, for that matter), i feel there should be a way to version python files. the current...
0
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work...
2
by: Kevin | last post by:
i have a python file called pyq which outputs stock quotes, currently i also have a html file that takes stock ticker inputs, i would like to bridge the two by building another program that takes...
10
by: mistral | last post by:
I have installed ActivePython http://www.activestate.com/Products/ActivePython/ How I can run Python file, test.py?
2
by: many_years_after | last post by:
Hi: some one said we can make a python file to an COM object through py2exe , but I haven't got the method. Could any one who knows tell me how to do? Thanks
4
by: Michael Malinowski | last post by:
Is there a way to read the directory that the currently running python file is located in? Cheers Mike.
2
by: yinglcs | last post by:
How to modify the source of a python file inside a python egg file? I can see the file by unzipping it, but how can I package it back as a python egg file after my modification. Thank you.
3
by: yinglcs | last post by:
Hi, i have 2 python files in *different directory* , how can I import python functions from 1 python file to another? i get this error: import task ImportError: No module named task/ Thank...
1
by: Seid Mohammed | last post by:
Greetins all 1. I can easily run python file from a comand prompt just typing "python filname.py". How can I do this from the python IDLE shell 2. How to create EXE in python. thanks all for...
0
by: Abdul Gbadamosi | last post by:
how can i pass an argument to a javascript script tag in html from a python file?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.