如何在Windows上安装PyCrypto ?

时间:2023-01-12 20:02:09

I've read every other google source and SO thread, with nothing working.

我已经阅读了所有谷歌源代码和线程,没有任何工作。

Python 2.7.3 32bit installed on Windows 7 64bit. Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat".

安装在Windows 7 64位上的Python 2.7.3 32位。下载,提取,然后尝试安装PyCrypto导致“无法找到vcvarsall.bat”。

So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error".

因此,我安装了MinGW,并将它作为选择的编译器安装在安装行上。但是我得到了错误的“运行时间错误:chmod错误”。

How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working).

我到底是怎么做到的?我试过用pip,结果是一样的。我发现了一个预建的PyCrypto 2.3二进制文件并安装了它,但是在系统上找不到它(不工作)。

Any ideas?

什么好主意吗?

18 个解决方案

#1


163  

If you don't already have a C/C++ development environment installed that is compatible with the Visual Studio binaries distributed by Python.org, then you should stick to installing only pure Python packages or packages for which a Windows binary is available.

如果您还没有安装与Python.org发布的Visual Studio二进制文件兼容的C/ c++开发环境,那么您应该坚持只安装纯Python包或Windows二进制可用的包。

Fortunately, there are PyCrypto binaries available for Windows: http://www.voidspace.org.uk/python/modules.shtml#pycrypto

幸运的是,有用于Windows的PyCrypto二进制文件:http://www.voidspace.org.uk/python/modules.shtml# PyCrypto。

UPDATE:
As @Udi suggests in the comment below, the following command also installs pycrypto and can be used in virtualenv as well:

更新:正如@Udi在评论中所建议的,下面的命令也安装了pycrypto,并且可以在virtualenv中使用:

easy_install http://www.voidspace.org.uk/python/pycrypto-2.6.1/pycrypto-2.6.1.win32-py2.7.exe

Notice to choose the relevant link for your setup from this list

请注意从这个列表中选择您的设置的相关链接。

If you're looking for builds for Python 3.5, see PyCrypto on python 3.5

如果您正在寻找Python 3.5的构建版本,请参阅Python 3.5中的PyCrypto。

#2


30  

Microsoft has recently recently released a standalone, dedicated Microsoft Visual C++ Compiler for Python 2.7. If you're using Python 2.7, simply install that compiler and Setuptools 6.0 or later, and most packages with C extensions will now compile readily.

微软最近发布了一个独立的、专用的Microsoft Visual c++编译器,用于Python 2.7。如果您使用的是Python 2.7,只需安装编译器和Setuptools 6.0或更高版本,并且大多数带有C扩展的包现在都可以轻松编译。

#3


17  

In general

vcvarsall.bat is part of the Visual C++ compiler, you need that to install what you are trying to install. Don't even try to deal with MingGW if your Python was compiled with Visual Studio toolchain and vice versa. Even the version of the Microsoft tool chain is important. Python compiled with VS 2008 won't work with extensions compiled with VS 2010!

vcvarsall。bat是Visual c++编译器的一部分,您需要它来安装您想要安装的内容。如果您的Python是用Visual Studio工具链编译的,那么就不要尝试处理MingGW,反之亦然。甚至微软工具链的版本也很重要。与VS 2008一起编译的Python将不会使用VS 2010编译的扩展!

You have to compile PyCrypto with the same compiler that the version of Python was compiled with. Google for "Unable to find vcvarsall.bat" because that is the root of your problem, it is a very common problem with compiling Python extensions on Windows.

您必须编译PyCrypto与Python版本编译的相同编译器。谷歌“找不到vcvarsall”。因为这是问题的根源,在Windows上编译Python扩展是一个非常常见的问题。

There is a lot of information and a lot to read to get this right on whatever system you are on with this link.

有很多信息和很多信息可以让你在任何系统上使用这个链接。

Beware using Visual Studio 2010 or not using Visual Studio 2008

As far as I know the following is still true. This was posted in the link above in June, 2010 referring to trying to build extensions with VS 2010 Express against the Python installers available on python.org.

据我所知,以下情况仍然属实。这是在2010年6月的链接上发布的,它指的是尝试在python.org上针对Python安装程序构建VS 2010 Express的扩展。

Be careful if you do this. Python 2.6 and 2.7 from python.org are built with Visual Studio 2008 compilers. You will need to link with the same CRT (msvcr90.dll) as Python.

如果你这样做,一定要小心。python.org上的Python 2.6和2.7是用Visual Studio 2008编译器构建的。您将需要使用与Python相同的CRT (msvcr90.dll)链接。

Visual Studio 2010 Express links with the wrong CRT version: msvcr100.dll.

Visual Studio 2010 Express链接错误的CRT版本:msvcr100.dll。

If you do this, you must also re-build Python with Visual Studio 2010 Express. You cannot use the standard Python binary installer for Windows. Nor can you use any C/C++ extensions built with a different compiler than Visual Studio 2010 (Express).

如果您这样做,您还必须使用Visual Studio 2010 Express重新构建Python。您不能使用标准的Python二进制安装程序来安装Windows。您也不能使用与Visual Studio 2010 (Express)不同的编译器构建的任何C/ c++扩展。

Opinion: This is one reason I abandoned Windows for all serious development work for OSX!

意见:这是我放弃Windows为OSX所有认真的开发工作的原因之一!

#4


16  

For VS2010:

VS2010:

SET VS90COMNTOOLS=%VS100COMNTOOLS%

For VS2012:

VS2012:

SET VS90COMNTOOLS=%VS110COMNTOOLS%

then Call:

然后调用:

pip install pyCrypto 

#5


15  

After years and years, python finally agreed for a binary disribution called wheel which allows to install even binary extensions on Windows without having a compiler with simple pip install packagename. There is a list of popular packages with their status. Pycrypto is not there yet, but lxml, PySide and Scrapy for example.

经过多年的努力,python最终同意了一个名为wheel的二进制文件,它允许在Windows上安装二进制扩展,而无需使用简单的pip安装packagename编译器。有一列有他们身份的受欢迎的包。Pycrypto还没有出现,但是lxml、PySide和Scrapy是一个例子。

Edited Nov 2015: pip uninstall pycrypto & pip install pycryptodome. It is a pycrypto fork with new features and it supports wheel. It replaces pycrypto, so existing code will continue to work (see https://pycryptodome.readthedocs.org/en/latest/src/examples.html)

2015年11月编辑:pip卸载pycrypto & pip安装pycryptodome。它是一个具有新功能的pycrypto分支,它支持*。它将替换pycrypto,因此现有代码将继续工作(参见https://pycryptodome.readthedocs.org/en/latest/src/examples.html)。

#6


11  

PyCryptodome is an almost-compatible fork of PyCrypto with Windows wheels available on pypi.

PyCryptodome是pypi上安装有Windows*的PyCrypto的一个几乎兼容的分支。

You can install it with a simple:

你可以简单地安装它:

pip install pycryptodome

The website includes instructions to build it from sources with the Microsoft compilers too.

该网站还包括了从源代码和微软编译器一起构建的指令。

#7


6  

I have managed to get pycrypto to compile by using MinGW32 and MSYS. This presumes that you have pip or easy_install installed.

通过使用MinGW32和MSYS,我成功地得到了pycrypto编译。这假定您安装了pip或easy_install。

Here's how I did it:

我是这样做的:

1) Install MinGW32. For the sake of this explanation, let's assume it's installed in C:\MinGW. When using the installer, which I recommend, select the C++ compiler. MSYS should install with MinGW

1)安装MinGW32。为了这个解释,让我们假设它安装在C:\MinGW。在使用安装程序时,我建议选择c++编译器。MSYS应该与MinGW一起安装。

2) Add c:\mingw\bin,c:\mingw\mingw32\bin,C:\MinGW\msys\1.0, c:\mingw\msys\1.0\bin and c:\mingw\msys\1.0\sbin to your %PATH%. If you aren't familiar, this article is very helpful.

2)加c:\mingw\bin,c:\ mingw32\bin, c:\mingw\msys\1.0,c:\mingw\ msys\1.0\bin和c:\mingw\msys\1.0\sbin到您的%PATH%。如果你不熟悉,这篇文章很有帮助。

3) From the search bar, run msys and the MSYS terminal will open. For those familiar with Cygwin, it works in a similar fashion.

3)从搜索栏,运行msys, msys终端将打开。对于那些熟悉Cygwin的人来说,它的工作方式类似。

4) From within the MSYS terminal pip install pycrypto should run without error after this.

4)从MSYS终端pip安装pycrypto后,运行无误。

#8


5  

For those of you looking for python 3.4 I found a git repo with an installer that just works. Here are the direct links for x64 and x32

对于那些寻找python 3.4的人来说,我发现了一个git repo,它安装了一个安装程序。这里是x64和x32的直接链接。

#9


4  

It's possible to build PyCrypto using the Windows 7 SDK toolkits. There are two versions of the Windows 7 SDK. The original version (for .Net 3.5) includes the VS 2008 command-line compilers. Both 32- and 64-bit compilers can be installed.

可以使用Windows 7 SDK工具包构建PyCrypto。Windows 7 SDK有两个版本。最初的版本(对于。net 3.5)包含VS 2008命令行编译器。可以安装32位和64位编译器。

The first step is to compile mpir to provide fast arithmetic. I've documented the process I use in the gmpy library. Detailed instructions for building mpir using the SDK compiler can be found at sdk_build

第一步是编译mpir提供快速算法。我已经记录了我在gmpy库中使用的过程。在sdk_build中可以找到使用SDK编译器构建mpir的详细说明。

The key steps to use the SDK compilers from a DOS prompt are:

从DOS提示符中使用SDK编译器的关键步骤是:

1) Run either vcvars32.bat or vcvars64.bat as appropriate.

1)要么vcvars32运行。蝙蝠或vcvars64。蝙蝠是合适的。

2) At the prompt, execute "set MSSdk=1"

2)在提示符下,执行“set MSSdk=1”

3) At the prompt, execute "set DISTUTILS_USE_SDK=1"

3)在提示符下,执行“set DISTUTILS_USE_SDK=1”

This should allow "python setup.py install" to succeed assuming there are no other issues with the C code. But I vaaguely remember that I had to edit a couple of PyCrypto files to enable mpir and to find the mpir libraries but I don't have my Windows system up at the moment. It will be a couple of days before I'll have time to recreate the steps. If you haven't reported success by then, I'll post the PyCrypto steps. The steps will assume you were able to compile mpir.

这应该允许“python设置”。py安装“以成功假设C代码没有其他问题。但我非常清楚地记得,我必须编辑几个PyCrypto文件来启用mpir并找到mpir库,但目前我还没有安装Windows系统。过几天我就有时间来重新设计这些步骤了。如果到那时你还没有报告成功,我将发布PyCrypto步骤。这些步骤将假定您能够编译mpir。

I hope this helps.

我希望这可以帮助。

#10


4  

For Windows 7:

Windows 7:

To install Pycrypto in Windows,

要在Windows中安装Pycrypto,

Try this in Command Prompt,

在命令提示符中尝试这个,

Set path=C:\Python27\Scripts (i.e path where easy_install is located)

设置路径= C:\ Python27 \(我的脚本。e路径,其中easy_install位于

Then execute the following,

然后执行以下,

easy_install pycrypto

easy_install pycrypto

For Ubuntu:

Ubuntu的:

Try this,

试试这个,

Download Pycrypto from "https://pypi.python.org/pypi/pycrypto"

从“https://pypi.python.org/pypi/pycrypto”下载Pycrypto

Then change your current path to downloaded path using your terminal and user should be root:

然后改变你当前的路径,使用你的终端和用户的下载路径为根:

Eg: root@xyz-virtual-machine:~/pycrypto-2.6.1#

如:root@xyz-virtual-machine:~ / pycrypto-2.6.1 #

Then execute the following using the terminal:

然后使用终端执行下列操作:

python setup.py install

python的设置。py安装

It's worked for me. Hope works for all..

它为我工作。适用于所有希望. .

#11


3  

So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error".

因此,我安装了MinGW,并将它作为选择的编译器安装在安装行上。但是我得到了错误的“运行时间错误:chmod错误”。

This error "RuntimeError: chmod error" occurs because the install script didn't find the chmod command.

这个错误“运行时错误:chmod错误”发生是因为安装脚本没有找到chmod命令。

How in the world do I get around this?

我到底是怎么做到的?

Solution

You only need to add the MSYS binaries to the PATH and re-run the install script.

您只需要将MSYS二进制文件添加到路径并重新运行安装脚本。

(N.B: Note that MinGW comes with MSYS so )

(N。B:请注意,MinGW是和MSYS一起来的

Example

For example, if we are in folder C:\<..>\pycrypto-2.6.1\dist\pycrypto-2.6.1>

例如,如果我们在文件夹C:\<. >\pycrypto-2.6.1\dist\pycrypto-2.6.1>。

C:\.....>set PATH=C:\MinGW\msys\1.0\bin;%PATH%
C:\.....>python setup.py install

C:\ .....>设置路径= C:\ MinGW \ msys \ 1.0 \ bin;%路径% C:\ .....> python设置。py安装

Optional: you might need to clean before you re-run the script:

可选:在重新运行脚本之前,您可能需要清理:

`C:\<..>\pycrypto-2.6.1\dist\pycrypto-2.6.1> python setup.py clean`

#12


2  

This probably isn't the optimal solution but you might download and install the free Visual C++ Express package from MS. This will give you the C++ compiler you need to compile the PyCrypto code.

这可能不是最优的解决方案,但是您可以从ms下载并安装免费的Visual c++ Express包,这将为您提供编译PyCrypto代码所需的c++编译器。

#13


2  

  1. Go to "Microsoft Visual C++ Compiler for Python 2.7" and continue based on "System Requirements" (this is what I did to put below steps together).

    去“Microsoft Visual c++编译器Python 2.7”,并继续基于“系统需求”(这就是我在下面的步骤中所做的)。

  2. Install setuptools (setuptools 6.0 or later is required for Python to automatically detect this compiler package) either by: pip install setuptools or download "Setuptools bootstrapping installer" source from, save this file somwhere on your filestystem as "ez_python.py" and install with: python ez_python.py

    安装setuptools (setuptools 6.0或以后的版本是Python需要自动检测这个编译器包)的方法:pip安装setuptools或下载“setuptools bootstrapping installer”源代码,将这个文件存储在您的filestystem上,如“ez_python”。并安装:python ez_python.py。

  3. Install wheel (wheel is recommended for producing pre-built binary packages). You can install it with: pip install wheel

    安装车轮(建议用于生产预构建的二进制包)。你可以安装它:pip安装轮。

  4. Open Windows elevated Command Prompt cmd.exe (with "Run as administrator") to install "Microsoft Visual C++ Compiler for Python 2.7" for all users. You can use following command to do so: msiexec /i C:\users\jozko\download\VCForPython27.msi ALLUSERS=1 just use your own path to file: msiexec /i <path to MSI> ALLUSERS=1

    打开Windows提升命令提示cmd。exe(以“运行管理员”的身份)为所有用户安装“Microsoft Visual c++编译器”。您可以使用以下命令来这样做:msiexec /i C:\users\jozko\download\VCForPython27。msi ALLUSERS=1只使用自己的路径文件:msiexec /i ALLUSERS=1。

  5. Now you should be able to install pycrypto with: pip install pycrypto

    现在您应该能够安装pycrypto: pip安装pycrypto。

#14


2  

Try just using:

试着使用:

pip install pycryptodome

or:

或者:

pip install pycryptodomex

Source: https://pypi.python.org/pypi/pycryptodome

来源:https://pypi.python.org/pypi/pycryptodome

#15


1  

So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error".

因此,我安装了MinGW,并将它作为选择的编译器安装在安装行上。但是我得到了错误的“运行时间错误:chmod错误”。

You need to install msys package under MinGW

您需要在MinGW下安装msys程序包。

如何在Windows上安装PyCrypto ?

and add following entries in your PATH env variable.

并在路径env变量中添加以下条目。

  • C:\MinGW\bin
  • C:\ MinGW \ bin
  • C:\MinGW\msys\1.0\bin [This is where you will find chmod executable]
  • C:\MinGW\msys\1.0\bin[这是你会找到chmod可执行文件的地方]

Then run your command from normal windows command prompt.

然后从正常的windows命令提示符运行您的命令。

#16


1  

My answer might not be related to problem mention here, but I had same problem with Python 3.4 where Crypto.Cipher wasn't a valid import. So I tried installing PyCrypto and went into problems.

我的答案可能与这里提到的问题无关,但我在Python 3.4中有同样的问题。密码不是有效的导入。所以我试着安装了PyCrypto,然后开始了问题。

After some research I found with 3.4 you should use pycryptodome.

经过一些研究,我发现有3.4你应该使用pycryptodome。

I install pycryptodome using pycharm and I was good.

我使用pycharm安装pycryptodome,我很好。

from Crypto.Cipher import AES

从加密。进口AES密码

#17


0  

Due to weird legal reasons, binaries are not published the normal way. Voidspace is normally the best second source. But since quite some time, voidspace maintainer did not update. Use the zip from [https://www.dropbox.com/s/n6rckn0k6u4nqke/pycrypto-2.6.1.zip?dl=0]

由于奇怪的法律原因,二进制文件并没有按正常的方式发布。Voidspace通常是最好的第二来源。但在相当长的一段时间内,voidspace维护者并没有更新。使用zip从[https://www.dropbox.com/s/n6rckn0k6u4nqke/pycrypto-2.6.1.zip?

#18


0  

Step 1: Install Visual C++ 2010 Express from here.

步骤1:从这里安装Visual c++ 2010 Express。

(Do not install Microsoft Visual Studio 2010 Service Pack 1 )

(不要安装Microsoft Visual Studio 2010 Service Pack 1)

Step 2: Remove all the Microsoft Visual C++ 2010 Redistributable packages from Control Panel\Programs and Features. If you don't do those then the install is going to fail with an obscure "Fatal error during installation" error.

步骤2:从控制面板\程序和功能中删除所有的Microsoft Visual c++ 2010再分配软件包。如果您不这样做,那么安装将会失败,在安装过程中出现一个模糊的“致命错误”。

Step 3: Install offline version of Windows SDK for Visual Studio 2010 (v7.1) from here. This is required for 64bit extensions. Windows has builtin mounting for ISOs like Pismo.

步骤3:从这里安装Visual Studio 2010 (v7.1)的Windows SDK的脱机版本。这是64位扩展所需要的。Windows为像Pismo这样的ISOs安装了内置系统。

Step 4: You need to install the ISO file with Pismo File Mount Audit Package. Download Pismo from here

步骤4:您需要使用Pismo文件安装审计包安装ISO文件。庇斯摩从这里下载了一条条纹路

Step 5: Right click the downloaded ISO file and choose mount with Pismo. Thereafter, install the Setup\SDKSetup.exe instead of setup.exe.

第5步:右击下载的ISO文件,并选择带有Pismo的mount。此后,安装设置\ SDKSetup。exe安装程序。

Step 6a: Create a vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 by changing directory to C:\Program Files (x86)\Microsoft Visual Studio version\VC\ on the command prompt. Type command on the command prompt: cd C:\Program Files (x86)\Microsoft Visual Studio version\VC\r

步骤6a:创建vcvars64。bat文件C:\Program Files (x86)\Microsoft Visual Studio 10.0 \ VC \ bin \ amd64通过改变目录C:\Program Files (x86)\Microsoft Visual Studio版本\ VC \在命令提示符。类型命令在命令提示符:cd \ VC \ r C:\Program Files (x86)\Microsoft Visual Studio版本

Step 6b: To configure this Command Prompt window for 64-bit command-line builds that target x86 platforms, at the command prompt, enter: vcvarsall x86 Click here for more options.

步骤6b:为64位的命令行构建这个命令提示窗口,在命令提示符下,输入:vcvarsall x86点击这里获取更多选项。

Step 7: At the command prompt, install the PyCrypto by typing: C:\Python3X>pip install -U your_wh_file

步骤7:在命令提示符下,通过键入:C:\Python3X>pip安装-U your_wh_file安装PyCrypto。

#1


163  

If you don't already have a C/C++ development environment installed that is compatible with the Visual Studio binaries distributed by Python.org, then you should stick to installing only pure Python packages or packages for which a Windows binary is available.

如果您还没有安装与Python.org发布的Visual Studio二进制文件兼容的C/ c++开发环境,那么您应该坚持只安装纯Python包或Windows二进制可用的包。

Fortunately, there are PyCrypto binaries available for Windows: http://www.voidspace.org.uk/python/modules.shtml#pycrypto

幸运的是,有用于Windows的PyCrypto二进制文件:http://www.voidspace.org.uk/python/modules.shtml# PyCrypto。

UPDATE:
As @Udi suggests in the comment below, the following command also installs pycrypto and can be used in virtualenv as well:

更新:正如@Udi在评论中所建议的,下面的命令也安装了pycrypto,并且可以在virtualenv中使用:

easy_install http://www.voidspace.org.uk/python/pycrypto-2.6.1/pycrypto-2.6.1.win32-py2.7.exe

Notice to choose the relevant link for your setup from this list

请注意从这个列表中选择您的设置的相关链接。

If you're looking for builds for Python 3.5, see PyCrypto on python 3.5

如果您正在寻找Python 3.5的构建版本,请参阅Python 3.5中的PyCrypto。

#2


30  

Microsoft has recently recently released a standalone, dedicated Microsoft Visual C++ Compiler for Python 2.7. If you're using Python 2.7, simply install that compiler and Setuptools 6.0 or later, and most packages with C extensions will now compile readily.

微软最近发布了一个独立的、专用的Microsoft Visual c++编译器,用于Python 2.7。如果您使用的是Python 2.7,只需安装编译器和Setuptools 6.0或更高版本,并且大多数带有C扩展的包现在都可以轻松编译。

#3


17  

In general

vcvarsall.bat is part of the Visual C++ compiler, you need that to install what you are trying to install. Don't even try to deal with MingGW if your Python was compiled with Visual Studio toolchain and vice versa. Even the version of the Microsoft tool chain is important. Python compiled with VS 2008 won't work with extensions compiled with VS 2010!

vcvarsall。bat是Visual c++编译器的一部分,您需要它来安装您想要安装的内容。如果您的Python是用Visual Studio工具链编译的,那么就不要尝试处理MingGW,反之亦然。甚至微软工具链的版本也很重要。与VS 2008一起编译的Python将不会使用VS 2010编译的扩展!

You have to compile PyCrypto with the same compiler that the version of Python was compiled with. Google for "Unable to find vcvarsall.bat" because that is the root of your problem, it is a very common problem with compiling Python extensions on Windows.

您必须编译PyCrypto与Python版本编译的相同编译器。谷歌“找不到vcvarsall”。因为这是问题的根源,在Windows上编译Python扩展是一个非常常见的问题。

There is a lot of information and a lot to read to get this right on whatever system you are on with this link.

有很多信息和很多信息可以让你在任何系统上使用这个链接。

Beware using Visual Studio 2010 or not using Visual Studio 2008

As far as I know the following is still true. This was posted in the link above in June, 2010 referring to trying to build extensions with VS 2010 Express against the Python installers available on python.org.

据我所知,以下情况仍然属实。这是在2010年6月的链接上发布的,它指的是尝试在python.org上针对Python安装程序构建VS 2010 Express的扩展。

Be careful if you do this. Python 2.6 and 2.7 from python.org are built with Visual Studio 2008 compilers. You will need to link with the same CRT (msvcr90.dll) as Python.

如果你这样做,一定要小心。python.org上的Python 2.6和2.7是用Visual Studio 2008编译器构建的。您将需要使用与Python相同的CRT (msvcr90.dll)链接。

Visual Studio 2010 Express links with the wrong CRT version: msvcr100.dll.

Visual Studio 2010 Express链接错误的CRT版本:msvcr100.dll。

If you do this, you must also re-build Python with Visual Studio 2010 Express. You cannot use the standard Python binary installer for Windows. Nor can you use any C/C++ extensions built with a different compiler than Visual Studio 2010 (Express).

如果您这样做,您还必须使用Visual Studio 2010 Express重新构建Python。您不能使用标准的Python二进制安装程序来安装Windows。您也不能使用与Visual Studio 2010 (Express)不同的编译器构建的任何C/ c++扩展。

Opinion: This is one reason I abandoned Windows for all serious development work for OSX!

意见:这是我放弃Windows为OSX所有认真的开发工作的原因之一!

#4


16  

For VS2010:

VS2010:

SET VS90COMNTOOLS=%VS100COMNTOOLS%

For VS2012:

VS2012:

SET VS90COMNTOOLS=%VS110COMNTOOLS%

then Call:

然后调用:

pip install pyCrypto 

#5


15  

After years and years, python finally agreed for a binary disribution called wheel which allows to install even binary extensions on Windows without having a compiler with simple pip install packagename. There is a list of popular packages with their status. Pycrypto is not there yet, but lxml, PySide and Scrapy for example.

经过多年的努力,python最终同意了一个名为wheel的二进制文件,它允许在Windows上安装二进制扩展,而无需使用简单的pip安装packagename编译器。有一列有他们身份的受欢迎的包。Pycrypto还没有出现,但是lxml、PySide和Scrapy是一个例子。

Edited Nov 2015: pip uninstall pycrypto & pip install pycryptodome. It is a pycrypto fork with new features and it supports wheel. It replaces pycrypto, so existing code will continue to work (see https://pycryptodome.readthedocs.org/en/latest/src/examples.html)

2015年11月编辑:pip卸载pycrypto & pip安装pycryptodome。它是一个具有新功能的pycrypto分支,它支持*。它将替换pycrypto,因此现有代码将继续工作(参见https://pycryptodome.readthedocs.org/en/latest/src/examples.html)。

#6


11  

PyCryptodome is an almost-compatible fork of PyCrypto with Windows wheels available on pypi.

PyCryptodome是pypi上安装有Windows*的PyCrypto的一个几乎兼容的分支。

You can install it with a simple:

你可以简单地安装它:

pip install pycryptodome

The website includes instructions to build it from sources with the Microsoft compilers too.

该网站还包括了从源代码和微软编译器一起构建的指令。

#7


6  

I have managed to get pycrypto to compile by using MinGW32 and MSYS. This presumes that you have pip or easy_install installed.

通过使用MinGW32和MSYS,我成功地得到了pycrypto编译。这假定您安装了pip或easy_install。

Here's how I did it:

我是这样做的:

1) Install MinGW32. For the sake of this explanation, let's assume it's installed in C:\MinGW. When using the installer, which I recommend, select the C++ compiler. MSYS should install with MinGW

1)安装MinGW32。为了这个解释,让我们假设它安装在C:\MinGW。在使用安装程序时,我建议选择c++编译器。MSYS应该与MinGW一起安装。

2) Add c:\mingw\bin,c:\mingw\mingw32\bin,C:\MinGW\msys\1.0, c:\mingw\msys\1.0\bin and c:\mingw\msys\1.0\sbin to your %PATH%. If you aren't familiar, this article is very helpful.

2)加c:\mingw\bin,c:\ mingw32\bin, c:\mingw\msys\1.0,c:\mingw\ msys\1.0\bin和c:\mingw\msys\1.0\sbin到您的%PATH%。如果你不熟悉,这篇文章很有帮助。

3) From the search bar, run msys and the MSYS terminal will open. For those familiar with Cygwin, it works in a similar fashion.

3)从搜索栏,运行msys, msys终端将打开。对于那些熟悉Cygwin的人来说,它的工作方式类似。

4) From within the MSYS terminal pip install pycrypto should run without error after this.

4)从MSYS终端pip安装pycrypto后,运行无误。

#8


5  

For those of you looking for python 3.4 I found a git repo with an installer that just works. Here are the direct links for x64 and x32

对于那些寻找python 3.4的人来说,我发现了一个git repo,它安装了一个安装程序。这里是x64和x32的直接链接。

#9


4  

It's possible to build PyCrypto using the Windows 7 SDK toolkits. There are two versions of the Windows 7 SDK. The original version (for .Net 3.5) includes the VS 2008 command-line compilers. Both 32- and 64-bit compilers can be installed.

可以使用Windows 7 SDK工具包构建PyCrypto。Windows 7 SDK有两个版本。最初的版本(对于。net 3.5)包含VS 2008命令行编译器。可以安装32位和64位编译器。

The first step is to compile mpir to provide fast arithmetic. I've documented the process I use in the gmpy library. Detailed instructions for building mpir using the SDK compiler can be found at sdk_build

第一步是编译mpir提供快速算法。我已经记录了我在gmpy库中使用的过程。在sdk_build中可以找到使用SDK编译器构建mpir的详细说明。

The key steps to use the SDK compilers from a DOS prompt are:

从DOS提示符中使用SDK编译器的关键步骤是:

1) Run either vcvars32.bat or vcvars64.bat as appropriate.

1)要么vcvars32运行。蝙蝠或vcvars64。蝙蝠是合适的。

2) At the prompt, execute "set MSSdk=1"

2)在提示符下,执行“set MSSdk=1”

3) At the prompt, execute "set DISTUTILS_USE_SDK=1"

3)在提示符下,执行“set DISTUTILS_USE_SDK=1”

This should allow "python setup.py install" to succeed assuming there are no other issues with the C code. But I vaaguely remember that I had to edit a couple of PyCrypto files to enable mpir and to find the mpir libraries but I don't have my Windows system up at the moment. It will be a couple of days before I'll have time to recreate the steps. If you haven't reported success by then, I'll post the PyCrypto steps. The steps will assume you were able to compile mpir.

这应该允许“python设置”。py安装“以成功假设C代码没有其他问题。但我非常清楚地记得,我必须编辑几个PyCrypto文件来启用mpir并找到mpir库,但目前我还没有安装Windows系统。过几天我就有时间来重新设计这些步骤了。如果到那时你还没有报告成功,我将发布PyCrypto步骤。这些步骤将假定您能够编译mpir。

I hope this helps.

我希望这可以帮助。

#10


4  

For Windows 7:

Windows 7:

To install Pycrypto in Windows,

要在Windows中安装Pycrypto,

Try this in Command Prompt,

在命令提示符中尝试这个,

Set path=C:\Python27\Scripts (i.e path where easy_install is located)

设置路径= C:\ Python27 \(我的脚本。e路径,其中easy_install位于

Then execute the following,

然后执行以下,

easy_install pycrypto

easy_install pycrypto

For Ubuntu:

Ubuntu的:

Try this,

试试这个,

Download Pycrypto from "https://pypi.python.org/pypi/pycrypto"

从“https://pypi.python.org/pypi/pycrypto”下载Pycrypto

Then change your current path to downloaded path using your terminal and user should be root:

然后改变你当前的路径,使用你的终端和用户的下载路径为根:

Eg: root@xyz-virtual-machine:~/pycrypto-2.6.1#

如:root@xyz-virtual-machine:~ / pycrypto-2.6.1 #

Then execute the following using the terminal:

然后使用终端执行下列操作:

python setup.py install

python的设置。py安装

It's worked for me. Hope works for all..

它为我工作。适用于所有希望. .

#11


3  

So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error".

因此,我安装了MinGW,并将它作为选择的编译器安装在安装行上。但是我得到了错误的“运行时间错误:chmod错误”。

This error "RuntimeError: chmod error" occurs because the install script didn't find the chmod command.

这个错误“运行时错误:chmod错误”发生是因为安装脚本没有找到chmod命令。

How in the world do I get around this?

我到底是怎么做到的?

Solution

You only need to add the MSYS binaries to the PATH and re-run the install script.

您只需要将MSYS二进制文件添加到路径并重新运行安装脚本。

(N.B: Note that MinGW comes with MSYS so )

(N。B:请注意,MinGW是和MSYS一起来的

Example

For example, if we are in folder C:\<..>\pycrypto-2.6.1\dist\pycrypto-2.6.1>

例如,如果我们在文件夹C:\<. >\pycrypto-2.6.1\dist\pycrypto-2.6.1>。

C:\.....>set PATH=C:\MinGW\msys\1.0\bin;%PATH%
C:\.....>python setup.py install

C:\ .....>设置路径= C:\ MinGW \ msys \ 1.0 \ bin;%路径% C:\ .....> python设置。py安装

Optional: you might need to clean before you re-run the script:

可选:在重新运行脚本之前,您可能需要清理:

`C:\<..>\pycrypto-2.6.1\dist\pycrypto-2.6.1> python setup.py clean`

#12


2  

This probably isn't the optimal solution but you might download and install the free Visual C++ Express package from MS. This will give you the C++ compiler you need to compile the PyCrypto code.

这可能不是最优的解决方案,但是您可以从ms下载并安装免费的Visual c++ Express包,这将为您提供编译PyCrypto代码所需的c++编译器。

#13


2  

  1. Go to "Microsoft Visual C++ Compiler for Python 2.7" and continue based on "System Requirements" (this is what I did to put below steps together).

    去“Microsoft Visual c++编译器Python 2.7”,并继续基于“系统需求”(这就是我在下面的步骤中所做的)。

  2. Install setuptools (setuptools 6.0 or later is required for Python to automatically detect this compiler package) either by: pip install setuptools or download "Setuptools bootstrapping installer" source from, save this file somwhere on your filestystem as "ez_python.py" and install with: python ez_python.py

    安装setuptools (setuptools 6.0或以后的版本是Python需要自动检测这个编译器包)的方法:pip安装setuptools或下载“setuptools bootstrapping installer”源代码,将这个文件存储在您的filestystem上,如“ez_python”。并安装:python ez_python.py。

  3. Install wheel (wheel is recommended for producing pre-built binary packages). You can install it with: pip install wheel

    安装车轮(建议用于生产预构建的二进制包)。你可以安装它:pip安装轮。

  4. Open Windows elevated Command Prompt cmd.exe (with "Run as administrator") to install "Microsoft Visual C++ Compiler for Python 2.7" for all users. You can use following command to do so: msiexec /i C:\users\jozko\download\VCForPython27.msi ALLUSERS=1 just use your own path to file: msiexec /i <path to MSI> ALLUSERS=1

    打开Windows提升命令提示cmd。exe(以“运行管理员”的身份)为所有用户安装“Microsoft Visual c++编译器”。您可以使用以下命令来这样做:msiexec /i C:\users\jozko\download\VCForPython27。msi ALLUSERS=1只使用自己的路径文件:msiexec /i ALLUSERS=1。

  5. Now you should be able to install pycrypto with: pip install pycrypto

    现在您应该能够安装pycrypto: pip安装pycrypto。

#14


2  

Try just using:

试着使用:

pip install pycryptodome

or:

或者:

pip install pycryptodomex

Source: https://pypi.python.org/pypi/pycryptodome

来源:https://pypi.python.org/pypi/pycryptodome

#15


1  

So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error".

因此,我安装了MinGW,并将它作为选择的编译器安装在安装行上。但是我得到了错误的“运行时间错误:chmod错误”。

You need to install msys package under MinGW

您需要在MinGW下安装msys程序包。

如何在Windows上安装PyCrypto ?

and add following entries in your PATH env variable.

并在路径env变量中添加以下条目。

  • C:\MinGW\bin
  • C:\ MinGW \ bin
  • C:\MinGW\msys\1.0\bin [This is where you will find chmod executable]
  • C:\MinGW\msys\1.0\bin[这是你会找到chmod可执行文件的地方]

Then run your command from normal windows command prompt.

然后从正常的windows命令提示符运行您的命令。

#16


1  

My answer might not be related to problem mention here, but I had same problem with Python 3.4 where Crypto.Cipher wasn't a valid import. So I tried installing PyCrypto and went into problems.

我的答案可能与这里提到的问题无关,但我在Python 3.4中有同样的问题。密码不是有效的导入。所以我试着安装了PyCrypto,然后开始了问题。

After some research I found with 3.4 you should use pycryptodome.

经过一些研究,我发现有3.4你应该使用pycryptodome。

I install pycryptodome using pycharm and I was good.

我使用pycharm安装pycryptodome,我很好。

from Crypto.Cipher import AES

从加密。进口AES密码

#17


0  

Due to weird legal reasons, binaries are not published the normal way. Voidspace is normally the best second source. But since quite some time, voidspace maintainer did not update. Use the zip from [https://www.dropbox.com/s/n6rckn0k6u4nqke/pycrypto-2.6.1.zip?dl=0]

由于奇怪的法律原因,二进制文件并没有按正常的方式发布。Voidspace通常是最好的第二来源。但在相当长的一段时间内,voidspace维护者并没有更新。使用zip从[https://www.dropbox.com/s/n6rckn0k6u4nqke/pycrypto-2.6.1.zip?

#18


0  

Step 1: Install Visual C++ 2010 Express from here.

步骤1:从这里安装Visual c++ 2010 Express。

(Do not install Microsoft Visual Studio 2010 Service Pack 1 )

(不要安装Microsoft Visual Studio 2010 Service Pack 1)

Step 2: Remove all the Microsoft Visual C++ 2010 Redistributable packages from Control Panel\Programs and Features. If you don't do those then the install is going to fail with an obscure "Fatal error during installation" error.

步骤2:从控制面板\程序和功能中删除所有的Microsoft Visual c++ 2010再分配软件包。如果您不这样做,那么安装将会失败,在安装过程中出现一个模糊的“致命错误”。

Step 3: Install offline version of Windows SDK for Visual Studio 2010 (v7.1) from here. This is required for 64bit extensions. Windows has builtin mounting for ISOs like Pismo.

步骤3:从这里安装Visual Studio 2010 (v7.1)的Windows SDK的脱机版本。这是64位扩展所需要的。Windows为像Pismo这样的ISOs安装了内置系统。

Step 4: You need to install the ISO file with Pismo File Mount Audit Package. Download Pismo from here

步骤4:您需要使用Pismo文件安装审计包安装ISO文件。庇斯摩从这里下载了一条条纹路

Step 5: Right click the downloaded ISO file and choose mount with Pismo. Thereafter, install the Setup\SDKSetup.exe instead of setup.exe.

第5步:右击下载的ISO文件,并选择带有Pismo的mount。此后,安装设置\ SDKSetup。exe安装程序。

Step 6a: Create a vcvars64.bat file in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 by changing directory to C:\Program Files (x86)\Microsoft Visual Studio version\VC\ on the command prompt. Type command on the command prompt: cd C:\Program Files (x86)\Microsoft Visual Studio version\VC\r

步骤6a:创建vcvars64。bat文件C:\Program Files (x86)\Microsoft Visual Studio 10.0 \ VC \ bin \ amd64通过改变目录C:\Program Files (x86)\Microsoft Visual Studio版本\ VC \在命令提示符。类型命令在命令提示符:cd \ VC \ r C:\Program Files (x86)\Microsoft Visual Studio版本

Step 6b: To configure this Command Prompt window for 64-bit command-line builds that target x86 platforms, at the command prompt, enter: vcvarsall x86 Click here for more options.

步骤6b:为64位的命令行构建这个命令提示窗口,在命令提示符下,输入:vcvarsall x86点击这里获取更多选项。

Step 7: At the command prompt, install the PyCrypto by typing: C:\Python3X>pip install -U your_wh_file

步骤7:在命令提示符下,通过键入:C:\Python3X>pip安装-U your_wh_file安装PyCrypto。