0

我正在尝试将一些 Python / Numpy 代码编译到 Cython 中以加快速度。我可以在我的桌面上很好地编译 - 我将我的 .pyx Cython 文件复制到我的笔记本电脑上运行它,在尝试编译后,我收到以下错误:

C:\Python27\MATH7450>python setup.py build_ext --inplace
running build_ext
cythoning heat.pyx to heat.c
building 'heat' extension
C:\strawberry\c\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\lib\site-pa
ckages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c heat.c -o bu
ild\temp.win32-2.7\Release\heat.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1

我正在运行 Windows 7 64 位。我看到它使用的是草莓 perl。我安装了 32 位版本的草莓 perl。同样,它在我的台式机上运行良好,但在移植到笔记本电脑时出现这个奇怪的错误。

4

2 回答 2

2

根据 Cython的Windows 安装说明,推荐的编译器是免费的 Visual C++ 2008 Express,可以通过离线安装Visual Studio 2008 Express iso进行安装。

或者Cython 可以使用 MinGW 及其 gcc,尽管据报道这是一条更困难的路线

从您的问题中包含的输出来看,Cython 正在尝试使用Strawberry Perl发行版中包含的 MinGW 安装。

我的建议是安装Visual C++ 2008 Express,根据我的经验,它最适合编译 Cython 或其他 Python C 扩展模块。

于 2012-10-23T20:44:17.743 回答
1

-mno-cygwininPython\Lib\distutils\cygwinccompiler.py导致此问题:请参阅使用 cython 和 mingw 编译产生 gcc:错误:无法识别的命令行选项 '-mno-cygwin'http://korbinin.blogspot.com/2013/03/cython-mno-cygwin-problems.html . 我的 Python 发行版(Anaconda)cygwinccompiler.py没有。无论如何,在删除类-mno-cygwin定义中的所有内容后,Mingw32CCompiler您应该能够编译。

于 2013-04-11T21:25:57.037 回答