I am currently trying to install pycrypto and when I execute python setup.py build I receive this following error:
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.9-intel-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.9-intel-2.7/Crypto/PublicKey/_fastmath.so
ld: illegal text-relocation to '___gmp_binvert_limb_table' in /usr/local/lib/libgmp.a(mp_minv_tab.o) from '___gmpn_divexact_1' in /usr/local/lib/libgmp.a(dive_1.o) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
I've already tried reinstalling the command line tools and removing old instances of Xcode.
Any help would be great thanks
This worked for me. (Should work if you are on Xcode 5.1)
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pycrypto
This did it for me:
sudo port install gmp
sudo ln -s /opt/local/lib/libgmp.dylib /usr/lib/libgmp.dylib
ARCHFLAGS=-Wno-error CFLAGS=-I/opt/local/include sudo -E pip install pycrypto
I ran into the same issue and was able to fix it by installing gmp:
brew install gmp
Then I nuked my build directory and started over with the pycrypto install and it succeeded.
This also fixes the warning message during pycrypto's configure script:
warning: GMP or MPIR library not found; Not building Crypto.PublickKey._fastmath
See related question.
On Yosemite:
CC=clang sudo -E pip install pycrypto
This works on Mojave and is better IMO than the other presented options:
brew install gmp
CFLAGS=-I/usr/local/include \
LDFLAGS=-L/usr/local/Cellar/gmp/6.1.2_2/lib \
pip install pycrypto
I noticed recently that I needed brew to install gmp to get pip install pycrypto working again after upgrading OSX 10.9 and Xcode 5. But then the gmp build started failing on illegal text-relocation. It seems a known issue 12946 causes the compiler to fail compiling position independent code:
cc -bundle -undefined dynamic_lookup -Wl,-F. -Wno-error=unused-command-line-argument-hard-error-in-future -Wno-error=unused-command-line-argument-hard-error-in-future build/temp.macosx-10.9-intel-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.9-intel-2.7/Crypto/PublicKey/_fastmath.so
ld: illegal text-relocation to '___gmp_binvert_limb_table' in /usr/local/lib/libgmp.a(mp_minv_tab.o) from '___gmpn_divexact_1' in /usr/local/lib/libgmp.a(dive_1.o) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
Similar to the answer provided by radiofrequency I symlinked the shared library of gmp into the system's /usr/lib directory as a workaround:
sudo ln -s /usr/local/Cellar/gmp/5.1.3/lib/libgmp.dylib /usr/lib/libgmp.dylib
The gmp developer should add --with-pic.
Side point: the number of warnings building pycrypto does not provide comfort.
on El Capitan I just did this ...
sudo easy_install livestreamer
sudo easy_install PyCrypto
et voila... I can now save streams to my HDD.
For those of you also looking to install pycrypto as well as the cryptography package, this is the command that ended up working for me:
env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
For installation of PyCrypto use MacPorts and following command. I tested it on the newest version of Mac OS X - Yosemite:
Python Version 2.7:
sudo port install py27-crypto
Python Version 3.4:
sudo port install py34-crypto
This is the only thing that worked for me on Mac/El Capitan:
sudo easy_install -U livestreamer
Install homebrew (single line for installation at bottom of page), then try:
$ sudo pip install pycrypto
If I'm not mistaken, pip and homebrew are both package managers, but homebrew is built on ruby and pip is built on python.
$ sudo pip install pycrypto
This command you referred to needs pip installed, not homebrew.
I'm a new comer to python; I experienced this problem also; and it vexed me. None of the solutions posted worked for me, so I archived libgmp.a and libgmp.la temporarily, and pip then installed Crypto without error. Is this an acceptable approach? I have no understanding as to why this worked...
来源:https://stackoverflow.com/questions/19617686/trying-to-install-pycrypto-on-mac-osx-mavericks