Search code examples
pythonpipfabricpycrypto

linker command failed at fastmath installing pycrypto on OSX


I did pip install pycrypto (actually wanted to install fabric but it failed at pycrypto) and got the error below. I'm on python 2.7.3. Tried 3.3 too but same error. How do I fix this please?

My clang version:

$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Error:

...

creating build/lib.macosx-10.7-x86_64-2.7/Crypto/Signature

copying lib/Crypto/Signature/__init__.py -> build/lib.macosx-10.7-x86_64-2.7/Crypto/Signature

copying lib/Crypto/Signature/PKCS1_PSS.py -> build/lib.macosx-10.7-x86_64-2.7/Crypto/Signature

copying lib/Crypto/Signature/PKCS1_v1_5.py -> build/lib.macosx-10.7-x86_64-2.7/Crypto/Signature

running build_ext

running build_configure

building 'Crypto.PublicKey._fastmath' extension

creating build/temp.macosx-10.7-x86_64-2.7

creating build/temp.macosx-10.7-x86_64-2.7/src

cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.7-x86_64-2.7/src/_fastmath.o

src/_fastmath.c:1545:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]

                        else if (result < 0)

                                 ~~~~~~ ^ ~

src/_fastmath.c:1621:20: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]

                        else if (result < 0)

                                 ~~~~~~ ^ ~

2 warnings generated.

cc -bundle -undefined dynamic_lookup -L/usr/local/lib build/temp.macosx-10.7-x86_64-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.7-x86_64-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

----------------------------------------

Command /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-riA3zG-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-build/pycrypto

Exception information:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
    status = self.run(options, args)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 261, in run
    requirement_set.install(install_options, global_options)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1166, in install
    requirement.install(install_options, global_options)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 589, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.py", line 612, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-riA3zG-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/_2/fwbd8jjn0mj_y_9w4f31g2nm0000gn/T/pip-build/pycrypto

Solution

  • I was using an HPC version of gcc. So I removed that and reinstalled Command Line Tools in Xcode. Then I was able to install pycrypto and fabric.