1

I'm using Mac with latest OS X update. I've trying to install PyCrypto over Terminal but I'm getting error which is shown on image below. The command I used is sudo pip install pycrypto. Can you please help me with this issue? How do I resolve this? Thanks for your answers.

enter image description here

Here is the error:

macfive:Desktop admin$ sudo pip install pycrypto
The directory '/Users/admin/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/admin/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pycrypto
  Downloading pycrypto-2.6.1.tar.gz (446kB)
    100% |████████████████████████████████| 450kB 2.4MB/s 
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-CYttJL/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mWAGUD-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py

.
.
.

src/hash_template.c:291: warning: return from incompatible pointer type
    src/hash_template.c: At top level:
    src/hash_template.c:306: error: initializer element is not constant
    src/hash_template.c:306: error: (near initialization for ‘ALG_functions[1].ml_name’)
    src/hash_template.c:306: error: initializer element is not constant
    src/hash_template.c:306: error: (near initialization for ‘ALG_functions[1].ml_meth’)
    fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't figure out the architecture type of: /var/tmp//ccCeO0Zf.out
    error: command 'gcc-4.2' failed with exit status 1

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-CYttJL/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mWAGUD-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-CYttJL/pycrypto/

Error is to big to copy it all. So I just copied the beginning and the end.

MattCodes
  • 489
  • 8
  • 21
  • Please copy paste the error text instead of a screenshot. – Railslide Sep 19 '16 at 08:03
  • I've updated my question and added error text. – MattCodes Sep 19 '16 at 08:13
  • you can download it from following link https://pypi.python.org/pypi/pycrypto and try to install with python setup.py install. Use Readme file for more details. – abhijeetmote Sep 19 '16 at 08:30
  • I've tried that and it wont work. Getting the same error. – MattCodes Sep 19 '16 at 08:36
  • Although it's on linux, have you seen this: [gcc-4-2-failed-with-exit-status-1](http://stackoverflow.com/questions/8473066/gcc-4-2-failed-with-exit-status-1)? – nostradamus Sep 19 '16 at 08:38
  • Yes, thank you very much for this link. It lead me to the right solution. I had to run `export CC=gcc` and `export CXX=g++`. I've been using the clang compiler, not gcc. – MattCodes Sep 19 '16 at 08:50

1 Answers1

1

You need to install the Python development files. I think it will work. Try

apt-get install autoconf g++ python2.7-dev 

Or

sudo apt-get install python-dev

Either one of the above and then this below one

pip install pycrypto
Sapanjeet
  • 66
  • 2