Cython致命错误:Python.h没有这样的文件或目录 [英] Cython Fatal Error: Python.h No such file or directory
问题描述
我一直使用Cython将我的Python文件编译成C文件,然后使用MinGW从C文件创建一个可执行文件。 Cython工作正常,我可以在命令行输入 cython test.pyx
并获得一个C文件。问题是当我尝试从C文件编译可执行文件时。如果我输入 gcc test.c
,会出现以下错误:
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.
我非常感谢您的帮助。我正在运行windows 7和python 3.5。
I would really appreciate some help. I am running windows 7 and python 3.5.
推荐答案
在gcc中
#include "file.h"
告诉gcc寻找该文件位于test.c所在的同一目录中,并且
tells gcc to find the file in the same directory where test.c is, and
#include <file.h>
表示在gcc包含路径中找到file.h,可以使用-I
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>
这篇关于Cython致命错误:Python.h没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!