user1798733
user1798733

Reputation:

Trying to install pycrypto on Mac OSX mavericks

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

Upvotes: 18

Views: 37191

Answers (14)

Shivam Kohli
Shivam Kohli

Reputation: 489

To install pycrypto run the following command

$ CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/Cellar/gmp/6.1.2_2/lib pip install pycrypto

Upvotes: 1

manimaul
manimaul

Reputation: 342

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

Upvotes: 8

GCU
GCU

Reputation: 39

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.

Upvotes: 3

chovy
chovy

Reputation: 75686

This is the only thing that worked for me on Mac/El Capitan:

sudo easy_install -U livestreamer

Upvotes: 1

Safronus
Safronus

Reputation: 19

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

Upvotes: 1

thinkski
thinkski

Reputation: 1302

On Yosemite:

CC=clang sudo -E pip install pycrypto

Upvotes: 9

Mullefa
Mullefa

Reputation: 1247

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...

Upvotes: 0

Nick Woodhams
Nick Woodhams

Reputation: 12677

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

Upvotes: 1

domino
domino

Reputation: 2165

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

Upvotes: 35

bbaassssiiee
bbaassssiiee

Reputation: 6802

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.

Upvotes: 2

Guto Hernandes
Guto Hernandes

Reputation: 17

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.

This way to get pip

Upvotes: 0

radiofrequency
radiofrequency

Reputation: 873

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

Upvotes: 12

einnocent
einnocent

Reputation: 3974

Install homebrew (single line for installation at bottom of page), then try:

$ sudo pip install pycrypto

Upvotes: 0

Chris Eldredge
Chris Eldredge

Reputation: 2951

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.

Upvotes: 9

Related Questions