"easy_install -U cython" 失败并抱怨 vcvarsall.bat 和 -mno-cygwin。

11

在Windows环境下,似乎带有C依赖项的easy_install并不那么容易。

尝试1 - vcvarsall.bat 错误

我正在使用MinGw在Windows 7上安装cython。我修改了Windows 7的PATH以包含C:\MinGw\bin。此时,我尝试运行easy_install -U cython,但遇到了...

C:\Users\mike_pennington\Desktop\TestDrive>easy_install -U cython
Searching for cython
Reading http://pypi.python.org/simple/cython/
Reading http://www.cython.org
Reading http://cython.org
Best match: Cython 0.15.1
Downloading http://cython.org/release/Cython-0.15.1.zip
Processing Cython-0.15.1.zip
Running Cython-0.15.1\setup.py -q bdist_egg --dist-dir c:\users\mike_p~1\appdata
\local\temp\easy_install-qr1tet\Cython-0.15.1\egg-dist-tmp-556kzq
Compiling module Cython.Plex.Scanners ...
Compiling module Cython.Compiler.Scanning ...
Compiling module Cython.Compiler.Parsing ...
Compiling module Cython.Compiler.Visitor ...
Compiling module Cython.Compiler.Code ...
Compiling module Cython.Runtime.refnanny ...
warning: no files found matching 'bugs.txt' under directory 'tests'
error: Setup script exited with error: Unable to find vcvarsall.bat

C:\Users\mike_pennington\Desktop\TestDrive>

尝试2 - 修复vcvarsall.bat错误

接下来,根据我发现的一篇博客上的建议,我也尝试将以下内容放入C:\Python27\Lib\distutils\distutils.cfg文件中,以修复vcvarsall.bat错误。

[build]
compiler=mingw32

这只能稍微起到一点帮助...

C:\Python27\Lib\DISTUT~1>easy_install -U cython
Searching for cython
Reading http://pypi.python.org/simple/cython/
Reading http://www.cython.org
Reading http://cython.org
Best match: Cython 0.15.1
Downloading http://cython.org/release/Cython-0.15.1.zip
Processing Cython-0.15.1.zip
Running Cython-0.15.1\setup.py -q bdist_egg --dist-dir c:\users\mike_p~1\appdata
\local\temp\easy_install-kfif_o\Cython-0.15.1\egg-dist-tmp-o1tbkp
Compiling module Cython.Plex.Scanners ...
Compiling module Cython.Compiler.Scanning ...
Compiling module Cython.Compiler.Parsing ...
Compiling module Cython.Compiler.Visitor ...
Compiling module Cython.Compiler.Code ...
Compiling module Cython.Runtime.refnanny ...
warning: no files found matching 'bugs.txt' under directory 'tests'
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: Setup script exited with error: command 'gcc' failed with exit status 1

C:\Python27\Lib\DISTUT~1>

注意事项 - 不使用cygwin或预编译二进制文件

我知道可能可以在cygwin下让这个工作,但是我不想在这个库中有cygwin依赖项;我需要本地Windows7输出。

如果可能的话,我想避免预编译的Cython二进制文件,因为正如作者所说,它们是“不支持的仅供测试目的”。

问题

如何在Windows7下使用MinGw通过easy_install安装cython

1个回答

15
经过一番搜索后,我找到了一份建议,建议从 C:\Python27\Lib\distutils\cygwinccompiler.py 中删除 -mno-cygwin,因为存在一个 distutils bug
C:\Python27\Lib\distutils\cygwinccompiler.py 中删除 -mno-cygwin 成功编译了 cython

1
这个修复对我没有用,反而引入了一个新的错误:`collect2: ld 返回 1 的退出状态错误:命令 'gcc' 执行失败,退出状态为 1` - EML
@MFB,您在删除“-mno-cygwin”后遇到了什么错误?Python的版本是多少? - Mike Pennington
1
@MikePennington,我去尝试重现错误,结果出现了一个全新的错误。抱歉给你带来困惑。新错误是“chmod error”,我曾认为这可能与UAC相关,但我已完全关闭它。有什么想法吗? - MFB

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接