【发布时间】:2016-02-18 00:48:25
【问题描述】:
我正在尝试在 OS X 10.11.3 (El Capitan) 上安装 PyCrypto。我正在使用 Python 3.5.1。我从https://pypi.python.org/pypi/pycrypto 下载了gzip 文件并解压。然后我按照说明运行python setup.py build,它似乎做了一些事情,然后它产生了这个输出:
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/MD2.c -o build/temp.macosx-10.6-intel-2.7/src/MD2.o
src/MD2.c:30:10: fatal error: 'string.h' file not found
#include <string.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
我尝试了python3 setup.py build 并得到了一些非常相似的输出:
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -fno-common -dynamic -fwrapv -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/MD2.c -o build/temp.macosx-10.6-intel-3.5/src/MD2.o
src/MD2.c:30:10: fatal error: 'string.h' file not found
#include <string.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
我尝试用谷歌搜索找出要做什么,但找不到任何有用的东西。如何安装 PyCrypto?
编辑:我还尝试了其他几种方法,例如 pip install pycrypto 和 sudo pip3 install pycrypto,但它们都不起作用。 @l'L'l 通过做一些我自己永远不会做的奇怪、复杂的事情来帮助我让它工作。它们总结在下面的答案中。
【问题讨论】:
-
您是否安装了 xcode 或命令行工具?您需要它才能使用标准库、llvm 等。
-
也许创建这个符号链接是可行的,假设 OS X 10.11 和 Xcode 7.x 存在同样的问题? gist.github.com/chrisyip/5b3cdb6a916f55354201#file-stdlib-h-md
-
事实上,其他人似乎遇到了与解决方案非常相似的问题stackoverflow.com/questions/13588518/…
-
你检查
ls -al /usr/include了吗?如果看起来不正确,不妨试试sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /usr/include? -
试试
unset DYLD_LIBRARY_PATH?
标签: python macos python-3.x osx-elcapitan pycrypto