Skip to content
This repository has been archived by the owner on May 13, 2019. It is now read-only.

fatal error: Python.h: No such file or directory #2

Open
mbdevpl opened this issue Aug 27, 2016 · 2 comments
Open

fatal error: Python.h: No such file or directory #2

mbdevpl opened this issue Aug 27, 2016 · 2 comments

Comments

@mbdevpl
Copy link

mbdevpl commented Aug 27, 2016

file testing.py contains the following:

print('hello world')

when compiling using cythonize the compilation succeeds:

$ cythonize -i testing.py 
running build_ext
building 'testing' extension
creating /tmp/cython_tests/tmprxz7ue8g/tmp
creating /tmp/cython_tests/tmprxz7ue8g/tmp/cython_tests
gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/user/.local/include/python3.5m -c /tmp/cython_tests/testing.c -o /tmp/cython_tests/tmprxz7ue8g/tmp/cython_tests/testing.o
gcc -pthread -shared /tmp/cython_tests/tmprxz7ue8g/tmp/cython_tests/testing.o -o /tmp/cython_tests/testing.cpython-35m-x86_64-linux-gnu.so

(also the compiled extension runs ok and hello world is printed)

but when using cytherize.py, there is a build error:

$ python3.5 ~/.local/bin/cytherize.py testing.py
cython -a -p -o /tmp/cython_tests/__cythercache__/testing.c /tmp/cython_tests/testing.py
gcc -fPIC -shared -w -O3 -I/home/user/.local/include/python3.5m-I/home/user/.local/include -L/home/user/.local/lib -o /tmp/cython_tests/testing.so /tmp/cython_tests/__cythercache__/testing.c -lpython3.5m
/tmp/cython_tests/__cythercache__/testing.c:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
Error in source file, see above

It seems Cython is using different flags to compile the extension than Cyther, and at least in my case the Cython flags seem to result in working binary, but not Cyther flags...

Am I supposed to add all the missing flags manually, or is this some to-be-resolved issue with Cyther?

@nickpandolfi
Copy link
Owner

Ok, I finally got around to attempting to fix this issue. This is definitely an issue to be resolved soon. Cyther is supposed to do it all for you. The problem for me is obtaining all of these platform / operating system dependent flags. I've tried many, many, many times to do this through distutils.ccompiler.CCompiler as well as its sub-classes, but the resulting mess is just simply nasty. Cython seems to be doing it internally (that is, figuring out the different flags necessary), and then just pass them to gcc. I don't even know where to start looking for where the flags are generated...

Thank you very much for the report though! It was very helpful,
Nick

@nickpandolfi
Copy link
Owner

I have successfully replicated the issue on a local Xubuntu installation. I'm very close to a fix!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants