【问题标题】:Error when trying to install PyCrypto尝试安装 PyCrypto 时出错
【发布时间】:2016-09-19 08:00:00
【问题描述】:

我正在使用带有最新 OS X 更新的 Mac。我试图在终端上安装 PyCrypto,但出现如下图所示的错误。我使用的命令是sudo pip install pycrypto。你能帮我解决这个问题吗?我该如何解决这个问题?感谢您的回答。

这是错误:

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/

错误太大,无法全部复制。所以我只是复制了开头和结尾。

【问题讨论】:

  • 请复制粘贴错误文本而不是屏幕截图。
  • 我已经更新了我的问题并添加了错误文本。
  • 您可以从以下链接pypi.python.org/pypi/pycrypto 下载它并尝试使用python setup.py install 进行安装。使用自述文件了解更多详细信息。
  • 我已经尝试过了,它不会工作。得到同样的错误。
  • 虽然是在linux上,但是你看到了吗:gcc-4-2-failed-with-exit-status-1?

标签: python pip pycrypto


【解决方案1】:

您需要安装 Python 开发文件。我认为它会起作用。试试

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

或者

sudo apt-get install python-dev

上面的一个,然后下面一个

pip install pycrypto

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 2017-10-11
    相关资源
    最近更新 更多