PyCrypto not fully installed on Windows XP

Question:

I ran python setup.py install in a Windows XP console, and it reported as follows:

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

When I try to run a script with import Crypto.Cipher.AES, it doesn’t work, saying:

ImportError: cannot import name AES

How can I fix this?

Asked By: jay

||

Answers:

On windows, it may just be easier installing PyCrypto via a prebuilt windows installer. The Voidspace site has PyCrypto 2.1 and 2.3 installers for Python 2.2-2.7.

Answered By: John Paulett

You may use PyPM to install (pre-built binary package of) 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

To list the files installed, type:

C:> pypm files pycrypto
C:UserssridharrAppDataRoamingPythonPython26
C:UserssridharrAppDataRoamingPythonPython26site-packages
C:UserssridharrAppDataRoamingPythonPython26site-packagesCrypto
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipher
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherAES.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherARC2.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherARC4.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherBlowfish.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherCAST.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherDES.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherDES3.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherIDEA.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherRC5.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipherXOR.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoCipher__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHash
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashHMAC.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashMD2.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashMD4.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashMD5.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashRIPEMD.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashSHA.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHashSHA256.pyd
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoHash__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoProtocol
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoProtocolAllOrNothing.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoProtocolChaffing.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoProtocol__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKey
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKeyDSA.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKeyElGamal.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKeyRSA.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKey__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKeypubkey.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoPublicKeyqNEW.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtil
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtilRFC1751.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtil__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtilnumber.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtilrandpool.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptoUtiltest.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCrypto__init__.py
C:UserssridharrAppDataRoamingPythonPython26site-packagesCryptotest.py
C:UserssridharrAppDataRoamingPythonPython26site-packagespycrypto-2.0.1-py2.6.egg-info

PyPM can be installed by installing ActivePython.

Answered By: Sridhar Ratnakumar

For other people like me on 64 bit windows 7:

Short version:
Follow this instructions.

Long version:

Install VC++ 2008 SP1 Express. you can get it from here.

You also need the Windows SDK, specifically the Win7 + Net 3.5 SDK.

Maybe the issue was already solved in your python version, if not get the diff file from the issue page

download patch.py (or any other tool to patch diff files)

if you downloaded the patch.py and diff file in c:Python27 just run:

python patch-11.01.py vcvars3.diff

Finally install using pip:

pip install pycrypto
Answered By: tovmeod
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.