The Python Oracle

How do I install PyCrypto on Windows?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Civilization

--

Chapters
00:00 Question
01:02 Accepted answer (Score 194)
01:57 Answer 2 (Score 34)
02:45 Answer 3 (Score 33)
03:13 Answer 4 (Score 20)
03:31 Thank you

--

Full question
https://stackoverflow.com/questions/1140...

Accepted answer links:
http://www.voidspace.org.uk/python/modul...
[this list]: http://www.voidspace.org.uk/python/pycry.../
[PyCrypto on python 3.5]: https://stackoverflow.com/q/32800336/456...

Answer 2 links:
[list of popular packages]: http://pythonwheels.com/
https://pycryptodome.readthedocs.org/en/...

Answer 3 links:
[Microsoft Visual C++ Compiler for Python 2.7]: http://www.microsoft.com/en-us/download/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #windows #python27 #pycrypto

#avk47



ACCEPTED ANSWER

Score 195


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.

Fortunately, there are PyCrypto binaries available for Windows: 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:

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




ANSWER 2

Score 37


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.

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)




ANSWER 3

Score 33


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.




ANSWER 4

Score 20


For VS2010:

SET VS90COMNTOOLS=%VS100COMNTOOLS%

For VS2012:

SET VS90COMNTOOLS=%VS110COMNTOOLS%

then Call:

pip install pyCrypto