Python Windows 上的 PyCrypto 安装错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13787258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 09:37:10  来源:igfitidea点击:

PyCrypto install error on Windows

pythonpython-3.xdistutilspycrypto

提问by Khurram Majeed

I am trying to install PyCrypto 2.6Library on my computer. But I keep getting the following error

我正在尝试在我的计算机上安装PyCrypto 2.6库。但我不断收到以下错误

D:\Software\Python\package\pycrypto-2.6>python setup.py build
running build
running build_py
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

building 'Crypto.Random.OSRNG.winrandom' extension
error: Unable to find vcvarsall.bat

My System has Windows 8 Pro 64-bit, Visual Studio Enterprise 2012 and Python 3.3

我的系统有 Windows 8 Pro 64 位、Visual Studio Enterprise 2012 和 Python 3.3

To fix the error I tried to set the Environment Variable VS90COMNTOOLS=%VS110COMNTOOLS%as advised by fmuecke in the post error: Unable to find vcvarsall.batbut it didn't work for me.

为了修复错误,我尝试VS90COMNTOOLS=%VS110COMNTOOLS%按照fmuecke 在帖子错误中的建议设置环境变量:无法找到 vcvarsall.bat但它对我不起作用。

Can any one please advise me how to fix this error.

任何人都可以请告诉我如何解决此错误。

FYI, I don't to install VC2008 etc..

仅供参考,我不安装 VC2008 等。

采纳答案by Khurram Majeed

I managed to install PyCrypto 2.6 by using the prebuilt binary for Python3.3from The Voidspace Python Modules.

我设法通过安装PyCrypto 2.6为Python3.3预建的二进制文件该Voidspace的Python模块

It doesn't actually fix the error: Unable to find vcvarsall.batfor other package which don't have a prebuilt binaries available.

它实际上并没有修复error: Unable to find vcvarsall.bat其他没有预构建二进制文件的包。

However it eliminates the need to build PyCrypto package, allowing me to install PyCrypto on my system without getting the error.

然而,它消除了构建 PyCrypto 包的需要,允许我在我的系统上安装 PyCrypto 而不会出现错误。

回答by GiorgioG

You may install mingw64 and then run from the PyCrypto unzipped files directory:

您可以安装 mingw64,然后从 PyCrypto 解压文件目录运行:

python setup.py build --compiler=mingw32

python setup.py build --compiler=mingw32

回答by user3842110

I know this is an old question, but I also need today much time to get paramiko wokring. I want to use Python 3.4 and on voidspace, there are no prebuild binaries for 3.4.

我知道这是一个老问题,但我今天也需要很多时间来获得 paramiko wokring。我想使用 Python 3.4 并且在 voidspace 上,没有 3.4 的预构建二进制文件。

Finally, I got a wokring pycrypto by installing "Microsoft Studio Express 2010 C++" and run from the pycrypto 2.7 folder:

最后,通过安装“Microsoft Studio Express 2010 C++”并从 pycrypto 2.7 文件夹运行,我得到了一个 wokring pycrypto:

python setup.py build --compiler msvc
python setup.py install
python setup.py bdist_wininst

All the "tricks" with enviroment variables doesn't work for me.

环境变量的所有“技巧”对我都不起作用。

If it helps somebody, all the thanks goes to: http://flintux.wordpress.com/2014/04/30/pycrypto-for-python-3-4-on-windows-7-64bit/

如果它对某人有帮助,那么感谢:http: //flintux.wordpress.com/2014/04/30/pycrypto-for-python-3-4-on-windows-7-64bit/

回答by One Time Guest

I've just used

我刚用

https://www.microsoft.com/en-gb/download/details.aspx?id=44266

https://www.microsoft.com/en-gb/download/details.aspx?id=44266

with setuptools > 6.0 and run

使用 setuptools > 6.0 并运行

'pip install pycrypto'

'pip 安装 pycrypto'

and it worked

它起作用了

回答by MordicusEtCubitus

For Python 3.5you can do this:

对于 Python 3.5,您可以这样做:

Install a PyCrypto binary from this site : https://github.com/sfbahr/PyCrypto-Wheels

从此站点安装 PyCrypto 二进制文件:https: //github.com/sfbahr/PyCrypto-Wheels

The best way to do it, is:

最好的方法是:

64bits Python

64 位 Python

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whlpycrypto

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links= https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1 -cp35-none-win_amd64.whlpycrypto

32bits Python

32位Python

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win32.whlpycrypto

c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links= https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1 -cp35-none-win32.whlpycrypto

Of course replace c:\Python35\Scripts\pip.exeby your python pip path

当然用你的 python pip 路径替换c:\Python35\Scripts\pip.exe

To know your python version, run python and look at the architecture displayed between brackets:

要了解您的 python 版本,请运行 python 并查看括号中显示的架构:

C:\Users\utilisateur>python Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit(AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

C:\Users\utilisateur>python Python 3.5.1 |Anaconda 4.0.0(64 位)| (默认,2016 年 2 月 16 日,09:49:46)[MSC v.1900 64 位( AMD64)] 在 win32 上键入“help”、“copyright”、“credits”或“license”以获取更多信息。

Hope this can help.

希望这能有所帮助。

回答by Reed Miller

I am using Windows 10 - All I needed to do was update my system with Visual C++ Build Tools 2015 which I found on this page: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/

我正在使用 Windows 10 - 我需要做的就是使用 Visual C++ Build Tools 2015 更新我的系统,我在此页面上找到了它:https: //blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-找到-vcvarsall-bat/

About mid-page, you will see some download options - choose your python version and download the correct package

关于中间页面,您将看到一些下载选项 - 选择您的 python 版本并下载正确的包

I then re-imported the program I was trying to install and NO more error! Woohoo!

然后我重新导入了我试图安装的程序,没有更多的错误!呜呼!

回答by hhhhhh

if you are VS 2010

如果你是 VS 2010

SET VS90COMNTOOLS=%VS100COMNTOOLS%

设置 VS90COMNTOOLS=%VS100COMNTOOLS%

VS 2012

VS 2012

SET VS90COMNTOOLS=%VS110COMNTOOLS%

设置 VS90COMNTOOLS=%VS110COMNTOOLS%

VS 2013

VS 2013

SET VS90COMNTOOLS=%VS120COMNTOOLS%

设置 VS90COMNTOOLS=%VS120COMNTOOLS%

and then python setup.py install

然后 python setup.py install

回答by sajanyamaha

got an easy way , hence sharing

有一个简单的方法,因此分享

  1. download the exe from https://www.dropbox.com/s/fhsvbl6d6ecs303/pycrypto-2.6.1.win-amd64-py3.4.exe?dl=0
  2. run easy_install C:\your\pathToDownloadedFile\Downloads\pycrypto-2.6.1.win-amd64-py3.4.exe
  1. https://www.dropbox.com/s/fhsvbl6d6ecs303/pycrypto-2.6.1.win-amd64-py3.4.exe?dl=0下载 exe
  2. easy_install C:\your\pathToDownloadedFile\Downloads\pycrypto-2.6.1.win-amd64-py3.4.exe