PyCrypto未完全安装在Windows XP上

2024-04-28 13:28:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Windows XP控制台中运行了python setup.py install,报告如下:

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

我该怎么解决?


Tags: installpyimportbuildwindows报告setupcrypto
3条回答

您可以使用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

可以通过安装ActivePython来安装PyPM。

在windows上,通过预先构建的windows安装程序安装PyCrypto可能更容易。空隙空间站点有PyCrypto 2.1 and 2.3 installers for Python 2.2-2.7

对于像我这样的64位Windows7用户:

短版本: 按照this说明操作。

长版本:

安装VC++2008 SP1 Express。你可以从here那里得到。

您还需要Windows SDK,特别是Win7 + Net 3.5 SDK

如果没有从问题页获得diff文件,那么在python版本中可能已经解决了issue

下载patch.py(或任何其他修补diff文件的工具)

如果在c:\Python27中下载了patch.py和diff文件,请运行:

python patch-11.01.py vcvars3.diff

最后使用pip安装:

pip install pycrypto

相关问题 更多 >