Pycrypto安装致命错误:找不到gmp.h文件
似乎有一些人有过类似的问题,但是,经过多次搜索后,我一直没能找到适合我的特定解决方案建筑。我试图安装Pycrypto(作为Fabric的子公司)无济于事。Pycrypto安装致命错误:找不到gmp.h文件
我正在运行Mac 10.8.2,python 2.7.3通过Homebrew和XCode 4.6 - 使用pip或easy_install进行安装(我尝试了两种方法)。从我所知道的问题来看,问题可能与我的XCode版本有关,也可能与我的库有关。 XCode的命令行工具已经安装,我已经尝试将setenv ARCHFLAGS "-arch i386 -arch x86_64"
放在我的.cshrc文件中。我也试过ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer
。至于图书馆,我试图通过ln -s /usr/local/lib/libgmp.dylib /usr/lib/libgmp.dylib
将它们链接起来 - 但这也行不通。
无论我尝试什么角度,错误总是相同的(见下文)。任何和所有的帮助,将不胜感激。
/usr/local/share/python% pip install pycrypto
Downloading/unpacking pycrypto
Running setup.py egg_info for package pycrypto
Installing collected packages: pycrypto
Running setup.py install for pycrypto
building 'Crypto.PublicKey._fastmath' extension
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -pipe -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wno-unused-value -Wno-empty-body -Qunused-arguments -fwrapv -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.8-intel-2.7/src/_fastmath.o
src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found
# include <gmp.h>
^
1 error generated.
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
Complete output from 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/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-Xb7nGV-record/install-record.txt --single-version-externally-managed:
running install
running build
running build_py
running build_ext
running build_configure
building 'Crypto.PublicKey._fastmath' extension
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -pipe -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wno-unused-value -Wno-empty-body -Qunused-arguments -fwrapv -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.8-intel-2.7/src/_fastmath.o
src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found
# include <gmp.h>
^
1 error generated.
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /usr/bin/clang' 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/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-Xb7nGV-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto
Storing complete log in /Users/me/.pip/pip.log
当我尝试调用面料的错误:
Traceback (most recent call last):
File "/usr/local/share/python/fab", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2815, in <module>
working_set.require(__requires__)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pycrypto>=2.1,!=2.4
只需连接gmppylib是没有帮助的,因为pycrpto需要编写一些C文件,其中将包括gmp.h.您应该安装包含gmp.h的GMP库。看来你必须在Mac OS上安装GMP。以下两个链接应该对你有所帮助。
这里是为我工作的修正:但崩溃
https://medium.com/software-bugs/84afab886a1e
您需要创建的基础上加装头一个符号链接包含路径(-I)。例如:
建筑物Crypto.PublicKey._fastmath'延伸
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno严格走样-fno- common -dynamic -pipe -march = native -mmacosx-version-min = 10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include -Wno-unused-value - Wno-empty-body -Qunused-arguments -fwrap v -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:36:11:致命错误:未找到
我能得到PyCrypto安装 'gmp.h' 文件使用下面的命令:
CFLAGS=-I/opt/local/include pip install pycrypto
我必须通过安装MacPorts的GMP,在OSX 10.8.3使用Python 2.7.2在python.org上运行。在这种情况下,我正在安装到virtualenv中。
我得到以下警告当使用PyCrypto,但它仍然有效:
/Users/me/.virtualenvs/blah/lib/python2.7/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
_warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
如果使用自制,这应该做的伎俩:
brew install gmp
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto
使用ENV将保证它只适用于这一次。如果您需要稍后在另一个会话中安装pycrypto,请改为输出该变量。
export "CFLAGS=-I/usr/local/include -L/usr/local/lib"
pip install pycrypto
为我完美工作,谢谢! – 2016-03-25 12:14:31
谢谢。 'env“CFLAGS = -I/usr/include/gmp -L/usr/lib/gmp”pip install pycrypto“在Solaris 11.3上为我工作。 – 2016-06-02 04:20:07
它的工作原理。非常感谢。你拯救了我的生命。 – harukaeru 2016-11-10 10:10:15
不幸的是,这些工作都没有。但是,谢谢。 – cosmosis 2013-03-22 00:40:27