Pycrypto安装致命错误:gmp.h找不到文件(Pycrypto install fatal e

2019-08-17 13:21发布

好像有很多人谁都有过类似的问题,但是,经过一番搜索我一直没能找到我的特殊架构有效的解决方案。 我试图安装Pycrypto(如面料的子公司)无济于事。

我通过自制软件运行Mac 10.8.2,蟒蛇2.7.3和4.6的XCode - 与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

Answer 1:

如果您使用的自制,这应该做的伎俩:

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


Answer 2:

我能得到PyCrypto使用下面的命令来安装:

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)


Answer 3:

因为pycrpto需要编写一些C文件,其中将包括gmp.h.只需连接gmppylib是无益 你应该有GMP库安装将包含gmp.h. 看来你必须在你的Mac OS安装GMP。 以下两个链接应该会对你有所帮助。

  • GMP和MPFR的Mac OS X上安装
  • 在Xcode在Mac OS X上安装GMP


Answer 4:

我终于明白了我的问题的根源是在面料和Pycrypto的版本之间的不兼容。 有一次,我降级我的版本面料到1.2.6,我不再有上面的错误。 然后,我用的教程作为起跳点。 然而,尽管本教程和旧版本的面料,我还是得到了PyCrypto >= 2.1, !=2.4的错误。 我(因为显然最终安装Pycrypto 2.2从源pip指定即使将只安装诉2.0.1 pip -Iv install pycrypto==2.2每本和v。2.6导致gmp.h错误)。 最后,一切正常。



Answer 5:

这里是为我工作的修补程序:

https://medium.com/software-bugs/84afab886a1e

您需要创建的基础上加装头一个符号链接包含路径(-I)中,但崩溃。 例:

建设“Crypto.PublicKey._fastmath”延伸

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno严格走样-fno共用-dynamic -pipe -march =天然-mmacosx版本分钟= 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 /应用/ Xcode.app /内容/开发/平台/ MacOSX.platform /开发商/软件开发工具包/ MacOSX10.7.sdk / usr / include目录-I /应用/ Xcode.app /目录/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include -Wno-未使用的值-Wno空体-Qunused论点-fwrapv -Wall -Wstrict的原型-std = C99 -O3 -fomit帧指针-Isrc / * -I / USR /包含/ - * I / USR /本地/地窖/蟒/ 2.7.3 /框架/ Python.framework /版本/ 2.7 /包含/ python2 0.7 -c SRC / _fastmath.c -o建立/ temp.macosx-10.7-x86_64-2.7 / SRC / _fastmath.o

SRC / _fastmath.c:36:11:致命错误: 'gmp.h' 文件没有找到



文章来源: Pycrypto install fatal error: gmp.h file not found