I'm running a CentOS 6.4 server with Python 2.7 (installed via PythonBrew script)
I have gmp installed via 'yum install gmp' and python-devel installed via 'yum install python-devel' (but it's for python 2.6 series)
I'm trying to install pycrypto on my server, but it's giving me
warning: GMP or MPIR library not found; Not building Crypto.PublickKey._fastmath
Is there any way to make pip 'recognize' my gmp installation?
Thanks : D
Just for anyone who runs across this in recent years, as I am sure there are/will be some. I was able to easily fix this issue on my Debian Jessie install by running the following command.
Then try your install again. In my case I was trying to install ansible via pip with the following command. Also for those to be able to come across this post with same scenario.
The output should now be the following.
I hope this helps someone down the road! - justin
Here is a step-by-step I've just made up on my CentOS server (the sequence assumes you're not root):
LIBGMP INSTALL
Firstly, setup and install libgmp somewhere in your home directory, as follows:
This will create a ~/lib, a ~/include and a ~/share directory if not existing already.
Then, add the following line to your .bashrc:
Do a ". ~/.bashrc" to enforce your changes.
PYCRYPTO BUILD & INSTALL
We need to deal with the install process manually. Firstly, we may download pycrypto as follows:
go into a directory where you store your sources:
cd ~/src
download pycrypto source archive:
curl -o pycrypto.tar.gz "https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz#md5=88dad0a270d1fe83a39e0467a66a22bb"
uncompress + untar archive:
gunzip pycrypto.tar.gz tar xvf pycrypto.tar
Then we need to cheat the configuration "a bit":
Edit the file cd src/config.h and amend the values for the definitions:
#define HAVE_DECL_MPZ_POWM 0 instead of 1
#define HAVE_DECL_MPZ_POWM_SEC 1 instead of 0
#define HAVE_LIBGMP 1 instead of 0
Then edit the setup.py file by searching for the keyword "_fastmath" and ensure that the Extension() declaration looks as per below:
Finally, build pycrypto with:
You should see somewhere in the trace the following line:
You can then do a "python setup.py install" or, if like me you prefer pip:
Then you should get no error when executing the following lines from python:
You are missing the C++ libraries to build this. Install VS 2017 https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
I got the above error when trying to install Fabric at the system level on Centos 6.4 using pip. (Fabric uses pycrypto).
This is how I got it working:
You probably need gmp-devel installed, too. This gives pycrypto the headers it needs to build using libgmp.
On Ubuntu, I only had libgmp10 installed. I hit the same warning when trying to install pycrypto. After installing the Ubuntu package libgmp-dev, the warning went away and the build script indicated it was using the _fastmath extension.
If you already installed pycrypto without _fastmath, you can reinstall it with the -I flag, e.g.
sudo pip install -I pycrypto