简体   繁体   English

尝试安装 PyCrypto 时出错

[英]Error when trying to install PyCrypto

I'm using Mac with latest OS X update.我正在使用带有最新 OS X 更新的 Mac。 I've trying to install PyCrypto over Terminal but I'm getting error which is shown on image below.我试图通过终端安装 PyCrypto,但出现错误,如下图所示。 The command I used is sudo pip install pycrypto .我使用的命令是sudo pip install pycrypto Can you please help me with this issue?你能帮我解决这个问题吗? How do I resolve this?我该如何解决? Thanks for your answers.感谢您的回答。

在此处输入图片说明

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.所以我只是复制了开头和结尾。

You need to install the Python development files.您需要安装 Python 开发文件。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM