Trying to install pycrypto on Mac OSX mavericks

隐身守侯 提交于 2019-11-30 03:16:45
domino

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
Chris Eldredge

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

bbaassssiiee

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

Safronus

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.

This way to get pip

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!