Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cython Fatal Error: Python.h No such file or directory

Tags:

python

c

gcc

cython

I have been using Cython to compile my Python files into C files and then use MinGW to create an executable from the C file. Cython works fine, I can type cython test.pyx into the command line and get a C file. The problem is when I attempt to compile an executable from the C file. If I type gcc test.c I get the following error:

test.c:4:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.

I would really appreciate some help. I am running windows 7 and python 3.5.

like image 524
Mark Skelton Avatar asked Jan 08 '16 02:01

Mark Skelton


People also ask

Where is the python h file?

The header files are typically installed with Python. On Unix, these are located in the directories prefix/include/pythonversion/ and exec_prefix/include/pythonversion/ , where prefix and exec_prefix are defined by the corresponding parameters to Python's configure script and version is '%d. %d' % sys.

What is python H?

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications.


1 Answers

you probably don't have python-dev installed. Depending on your OS, you'd need to do something like this:

sudo apt-get install python-dev

Which is what you'd do on Ubuntu

like image 79
bruceg Avatar answered Sep 28 '22 18:09

bruceg