I have a distutils setup script with an Extension section, which looks something like this:
from distutils.core import setup, Extension
my_module = Extension('my_module',
sources = ['my_file.c', 'my_other_file.c'])
setup (name = 'my_module',
version = '1.0',
description = 'My module',
ext_modules = [my_module])
Running setup.py build
works fine on my Mac. When I move to a Debian machine, it fails:
error: Python/Python.h: No such file or directory
I have python2.6
and python2.6-dev
installed, and the file is present at /usr/include/Python2.6
.
The command it executes for the problem file:
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c my_module.c -o -build/XYZ/my_module.o
So it is passing in the location of the header file.
The only obvious difference between the Mac vs Linux environment is gcc-4.2 vs gcc-4.4 and Python 2.7 vs Python 2.6
Ideas?
EDIT:
In the C file in question:
#include <Python/Python.h>
#include <Python/structmember.h>
May be in your module, you need to include "Python.h"
instead of "Python/Python.h"
?
or you may try exporting include path, and try compiling again with gcc or g++?
export C_INCLUDE_PATH=/usr/include/python2.6:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/python2.6:$CPLUS_INCLUDE_PATH
In my case, I was missing python3-dev, sudo apt-get install python3-dev
fixed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With