【发布时间】:2014-11-28 17:38:25
【问题描述】:
我已经花了 2 天时间尝试了我在这个网站上看到的所有其他内容。我试图让 cython 在 python 中编译基本的 helloworld 脚本,但是有错误。 Gcc 似乎无法看到 python 头文件,尽管列出的路径是正确的并且我已经验证了文件在那里(例如 c:/Python27/include/pyconfig.h) 我已经包含了使用的文件我的设置。
helloWorld.pyx
print 'Hello World'
setup.py
>from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("helloWorld.pyx")
)
命令行
python setup.py build_ext --inplace --compiler=mingw32
错误
编译 helloworld.pyx 因为它发生了变化。 Cythonizing helloworld.pyx 运行 build_ext 构建“helloworld”扩展 C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Pytho n27\PC -c helloworld.c -o build\temp.win32-2.7\Release\helloworld.o 在包含的文件中 helloworld.c:8: C:/Python27/include/pyconfig.h:68:16: io.h: 没有 文件或目录 C:/Python27/include/pyconfig.h:296:20: stdio.h: 否 这样的文件或目录在包含的文件中 C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/include/limits.h:122 ,来自 C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/include/syslimits.h: 7,来自 C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/include/limits.h:11,来自 C:/Python27/include/Python.h:19,来自 helloworld.c:16: /mingw/lib/gcc/mingw32/3.4.5/include/limits.h:122:61:limits.h:否 这样的文件或目录在 helloworld.c:16 包含的文件中: C:/Python27/include/Python.h:35:5: #error "Python.h 要求 stdio.h 定义 NULL。” C:/Python27/include/Python.h:38:20: string.h: 否 这样的文件或目录 C:/Python27/include/Python.h:40:19: errno.h: 否 这样的文件或目录 C:/Python27/include/Python.h:42:20: stdlib.h: 没有这样的文件或目录 C:/Python27/include/Python.h:56:20: assert.h:在包含的文件中没有这样的文件或目录 C:/Python27/include/Python.h:58,来自 helloworld.c:16: C:/Python27/include/pyport.h:325:76: math.h: 没有这样的文件或目录 C:/Python27/include/pyport.h:338:18:time.h: 没有这样的文件或目录 C:/Python27/include/pyport.h:390:22: sys/stat.h: 没有这样的文件或 目录在 C:/Python27/include/Python.h:80 包含的文件中,来自 helloworld.c:16: C:/Python27/include/object.h:307: 错误:语法错误 在“文件”C:/Python27/include/object.h:459 之前:错误:语法错误 在“文件”之前从 C:/Python27/include/Python.h:85 包含的文件中, 来自 helloworld.c:16: C:/Python27/include/unicodeobject.h:57:19: ctype.h:没有这样的文件或目录 C:/Python27/include/unicodeobject.h:120:21: wchar.h: 没有这样的文件或 目录在 C:/Python27/include/Python.h:108 包含的文件中,来自 helloworld.c:16: C:/Python27/include/fileobject.h:12: 错误:语法 “文件” C:/Python27/include/fileobject.h:12 之前的错误:警告:否 结构或联合末尾的分号 C:/Python27/include/fileobject.h:15: 错误: '' 之前的语法错误 令牌 C:/Python27/include/fileobject.h:33: 错误:之前的语法错误 '}' 标记 C:/Python27/include/fileobject.h:33:警告:类型默认值 到
int' in declaration ofPyFileObject' C:/Python27/include/fileobject.h:33:警告:数据定义没有 类型或存储类 C:/Python27/include/fileobject.h:44: 错误: '' 标记 C:/Python27/include/fileobject.h:45 之前的语法错误: 错误:“”标记之前的语法错误 C:/Python27/include/fileobject.h:46: 错误: '' 之前的语法错误 令牌 C:/Python27/include/fileobject.h:46:警告:类型默认为int' in declaration of PyFile_AsFile' C:/Python27/include/fileobject.h:46: warning: data definition has no type or storage class C:/Python27/include/fileobject.h:47: error: syntax error before '*' token C:/Python27/include/fileobject.h:48: error: syntax error before '*' token C:/Python27/include/fileobject.h:65: error: syntax error before "FILE" C:/Python27/include/fileobject.h:66: error: syntax error before "FILE" In file included from C:/Python27/include/Python.h:127, from helloworld.c:16: C:/Python27/include/pythonrun.h:35: error: syntax error before '*' token C:/Python27/include/pythonrun.h:36: error: syntax error before '*' token C:/Python27/include/pythonrun.h:38: error: syntax error before '*' token C:/Python27/include/pythonrun.h:39: error: syntax error before '*' token C:/Python27/include/pythonrun.h:40: error: syntax error before '*' token C:/Python27/include/pythonrun.h:45: error: syntax error before '*' token C:/Python27/include/pythonrun.h:55: error: syntax error before '*' token C:/Python27/include/pythonrun.h:61: error: syntax error before '*' token C:/Python27/include/pythonrun.h:78: error: syntax error before '*' token C:/Python27/include/pythonrun.h:152: error: syntax error before '*' token C:/Python27/include/pythonrun.h:154: error: syntax error before '*' token In file included from C:/Python27/include/Python.h:129, from helloworld.c:16: C:/Python27/include/sysmodule.h:12: error: syntax error before '*' token C:/Python27/include/sysmodule.h:12: error: syntax error before "FILE" C:/Python27/include/sysmodule.h:12: warning: type defaults toint' 在PySys_GetFile' C:/Python27/include/sysmodule.h:12: warning: data definition has no type or storage class In file included from C:/Python27/include/Python.h:131, from helloworld.c:16: C:/Python27/include/import.h:39: error: syntax error before "FILE" helloworld.c: In function__PYX_NAN' 的声明中:helloworld.c:315:警告: 函数memset' helloworld.c: In function__Pyx_PyUnicode_FromString'的隐式声明:helloworld.c:1423:警告:隐式 函数声明strlen' helloworld.c: In function__Pyx_PyObject_AsStringAndSize':helloworld.c:1474:警告:隐式 声明函数“断言”错误:命令 'C:\MinGW\bin\gcc.exe' 失败,退出状态为 1
【问题讨论】:
-
看起来它正在查找 Python 头文件,但未能找到 C 标准库头文件。您确定您安装的 MinGW 确实有效吗?