2009-11-06 175 views
29

我在Windows XP控制檯運行python setup.py install,並報告如下:PyCrypto沒有完全安裝在Windows XP

running install 
running build 
running build_py 
running build_ext 
warning: GMP library not found; Not building Crypto.PublicKey._fastmath. 
building 'Crypto.Random.OSRNG.winrandom' extension 
error: None 

當我嘗試用import Crypto.Cipher.AES運行一個腳本,它不工作,他說:

ImportError: cannot import name AES 

我該如何解決這個問題?

回答

43

在windows上,它可能更容易通過預安裝的Windows安裝程序安裝PyCrypto。 Voidspace站點有PyCrypto 2.1 and 2.3 installers for Python 2.2-2.7

+0

它的工作!謝謝。 – jay 2009-11-06 13:51:10

+0

沒有版本的win64 :( – tovmeod 2012-07-10 01:19:41

+1

)Voidspace的PyCrypto 2.6版本包括32位和64位版本,每個支持的Python版本 – 2012-10-23 13:33:47

0

您可以使用PyPM安裝(預編譯的二進制包)pycrypto:

C:> pypm install pycrypto 
Ready to perform these actions: 
The following packages will be installed: 
pycrypto-2.0.1 
Get: [pypm.activestate.com] pycrypto 2.0.1-1 
Installing pycrypto-2.0.1 

要列出安裝的文件,鍵入:

C:> pypm files pycrypto 
C:\Users\sridharr\AppData\Roaming\Python\Python26 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\AES.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\ARC2.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\ARC4.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\Blowfish.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\CAST.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\DES.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\DES3.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\IDEA.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\RC5.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\XOR.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Cipher\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\HMAC.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\MD2.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\MD4.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\MD5.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\RIPEMD.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\SHA.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\SHA256.pyd 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Hash\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Protocol 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Protocol\AllOrNothing.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Protocol\Chaffing.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Protocol\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\DSA.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\ElGamal.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\RSA.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\pubkey.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\PublicKey\qNEW.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util\RFC1751.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util\number.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util\randpool.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\Util\test.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\__init__.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\Crypto\test.py 
C:\Users\sridharr\AppData\Roaming\Python\Python26\site-packages\pycrypto-2.0.1-py2.6.egg-info 

PyPM可以通過安裝ActivePython安裝。

+1

_error:Can'安裝pycrypto-2.5:需要Business Edition subscription_ – 2012-06-28 13:24:58

+1

@DavidFreitas - 嘗試使用ActivePython 32位而不是64位。 – 2012-07-16 19:37:28

3

對於其他人跟我一樣在64位Windows 7:

短版: 按照this說明。

長版本:

安裝VC++ 2008 SP1 Express。你可以從here得到它。

您還需要Windows SDK,特別是Win7 + Net 3.5 SDK

也許issue已經解決了你的Python版本,如果沒有得到問題頁面的差異文件

下載patch.py(或任何其他工具來修補差異文件)

,如果你下載的補丁的.py和DIFF在c:\Python27文件只需要運行:

python patch-11.01.py vcvars3.diff 

最後安裝使用PIP:

pip install pycrypto