Cython 安装错误

3

运行 easy_install Cython 时出错:

C:\Users\Hp>cd C:\Python27\Scripts

C:\Python27\Scripts>easy_install Cython
Searching for Cython
Reading http://pypi.python.org/simple/Cython/
Best match: Cython 0.19.1
Downloading https://pypi.python.org/packages/source/C/Cython/Cython-0.19.1.zip
d5=991e7887140b3e962ef65e9c05a8694d
Processing Cython-0.19.1.zip
Running Cython-0.19.1\setup.py -q bdist_egg --dist-dir c:\users\hp\appdata\loc
\temp\easy_install-jfquni\Cython-0.19.1\egg-dist-tmp-yxdubl
Compiling module Cython.Plex.Scanners ...
Compiling module Cython.Plex.Actions ...
Compiling module Cython.Compiler.Lexicon ...
Compiling module Cython.Compiler.Scanning ...
Compiling module Cython.Compiler.Parsing ...
Compiling module Cython.Compiler.Visitor ...
Compiling module Cython.Compiler.FlowControl ...
Compiling module Cython.Compiler.Code ...
Compiling module Cython.Runtime.refnanny ...
warning: no files found matching '*.pyx' under directory 'Cython\Debugger\Test

warning: no files found matching '*.pxd' under directory 'Cython\Debugger\Test

warning: no files found matching '*.h' under directory 'Cython\Debugger\Tests'
warning: no files found matching '*.pxd' under directory 'Cython\Utility'
error: Setup script exited with error: Unable to find vcvarsall.bat

我碰到了这个错误,显然需要一些开发文件,但不确定如何在Windows上获取它?


1
你安装了编译器吗? - user2665694
1
“无法找到vcvarsall.bat”明确表示您的系统正在寻找VisualC的编译器。我建议安装MinGW并按照此处所述进行操作:https://dev59.com/B3PYa4cB1Zd3GeqPeQki#16980330 - Gauthier Boaglio
2个回答

2

我也遇到了vcvarsall.bat的问题,以下是我解决这个问题的步骤,适用于Windows 8和Python 3.4:

关于安装Cython有两个选项:从第一步开始或直接跳转到第二步:

第一步

不使用pip安装Cython:

我从这里下载了适用于我的版本的.whl文件:

然后执行以下命令安装.whl文件:

pip install filename.whl

这样,Cython就不会抱怨vcvarshall.bat了。
现在你已经安装了Cython,可以创建C代码,但是在创建.pyd文件时会出现问题,一旦开始编译代码,就会显示与vcvarshall.bat缺失相同的错误。因此需要进行第二步操作。
  1. Install MinGW

  2. Go to C:\Python34\Lib\distutils\

    Create the file distutils.cfg and write:

    [build]
    compiler = mingw32
    
  3. Add to your path C:\MinGW\bin

  4. Now you can reinstall the .whl or directly install Cython from: pip install cython

当您尝试调用Cython时,仍可能会出现错误:

   zlib1.dll was not found
  1. 从这里下载:

    http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib123-dll.zip/download?use_mirror=iweb&download=

  2. 解压文件夹并将zlib1.dll复制粘贴到C:\MinGW\bin

现在Cython应该可以正常工作了。

我在某些帖子中读到了一些建议,说解决方法是安装MVS 2008,但它已经被弃用了,所以我不建议选择此选项。

这个解决方案是我找到并尝试了多个答案的组合,直到我得到正确的解决方案,我附上了链接,以便您查看其他解决方案或观点:

https://dev59.com/B3PYa4cB1Zd3GeqPeQki#16980330

如何安装Cython

运行Python脚本时找不到vcvarsall.bat


0

我的病毒检测器刚刚将refnanny.pyd标记为病毒并将其删除。显然它触发了某种启发式匹配。


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