Results 1 to 4 of 4
I am trying to embed some C code in Python, and I have a C program that includes Python.h. When I try to compile it it says
"fatal error: Python.h: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-12-2012 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 11
Python.h not found
I am trying to embed some C code in Python, and I have a C program that includes Python.h. When I try to compile it it says
"fatal error: Python.h: No such file or directory"
though I have Python.h in /usr/include/python2.7. Anyone know what's wrong?
- 03-12-2012 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,143
It depends upon two things. 1) is what include directories you have specified in your makefile with the -I <dir> flag, and 2) is how you specified the include file with the #include <file> directive in your code. If #2 was "#include <python.h>", then you need the flag "-I /usr/include/python2.7" in the CFLAGS section of your makefile.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-12-2012 #3Just Joined!
- Join Date
- Sep 2011
- Posts
- 11
Then would I have to use make to compile this C program, or run the python program that calls it? Or can I still use gcc/python. And can you tell me where makefile is?
Thanks.
- 03-13-2012 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,143
You need to build the C code first. As for the makefile for your C code, that depends. Usually it is created dynamically by either a configure script (autoconf), or a set of cmake rules. These are two common methods used to interrogate the operating system for installed software to see what it is capable of, creating the appropriate Makefile with the flags needed to build the tool in question. So what is this program that you are trying to get to work with Python?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
