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

≡放荡痞女 提交于 2019-12-23 09:32:02

问题


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.


回答1:


in gcc

#include "file.h"

tells gcc to find the file in the same directory where test.c is, and

#include <file.h>

means to find file.h in the gcc include paths, which can be added with -I

gcc -I/path/to/the/file_h test.c

you might try

#include <Python.h>

also see fatal error: Python.h: No such file or directory




回答2:


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



来源:https://stackoverflow.com/questions/34668675/cython-fatal-error-python-h-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!