PyCrypto on python 3.5

Trsak picture Trsak · Sep 26, 2015 · Viewed 70.7k times · Source

I found some PyCrypto installers for Python 3.3 and 3.4, but nothing for Python 3.5.

When I try to install PyCrypton using pip install, it says:

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.  

Is there any way to install PyCrypto on Python 3.5 in Windows 10? Thanks!

Answer

sfbahr picture sfbahr · Oct 26, 2015

That warning shouldn't stop the build, more likely you are lacking the Visual Studio 2015 compiler which is necessary to build binary extensions (which PyCrypto has). See the Python Packaging User Guide for which compiler you need for your version of Python.

The reason you need the compiler is PyCrypto only offers a Source Distribution officially. So, you have two options for installing PyCrypto:

1. Build from source:

This is actually fairly simple, but it requires that you install some extra software. Again, refer to the Python Packaging User Guide linked above to find the suitable compiler for your version of Python. I think that there is an option to only install the relevant compiler for Python if you do a custom install of Visual Studio.

Then, after the installation is completed, and you probably had to restart your computer, you should be able to simply run pip install pycrypto and pip will download the source and compile it for you.

If you also installed wheel (pip install wheel) then pip will create a wheel from the source and cache it, which is how I created the wheels that I'm sharing in option 2.

2. Install a Built Distribution from a 3rd party

I happen to be a 3rd party and have shared wheels I compiled for PyCrypto 2.6.1 w/ Python 3.5 for 32 and 64-bit Windows on my GitHub repo. I included installation instructions on the readme of that repo.

If you're looking for a built distribution for an older version of Python and/or PyCrypto, I've also linked to Voidspace on my repo's readme (sorry, I'm limited to 2 links here).