Pycrypto install error fatal: gmp.h archivo no encontrado


Parece que hay un número de personas que han tenido un problema similar, sin embargo, después de mucho buscar no he sido capaz de encontrar una solución que funcione con mi arquitectura particular. Estoy tratando de instalar Pycrypto (como una subsidiaria de Fabric) en vano.

Estoy ejecutando Mac 10.8.2, python 2.7.3 a través de Homebrew y XCode 4.6 installing instalando con pip o easy_install (he probado ambos). Por lo que puedo decir, el problema podría ser con respecto a mi versión de XCode o por mis bibliotecas. Las Herramientas de Línea de comandos para XCode se han instalado y he intentado colocar setenv ARCHFLAGS "-arch i386 -arch x86_64" en mi .archivo cshrc. También he intentado ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer. En cuanto a las bibliotecas, he intentado vincularlas a través de ln -s /usr/local/lib/libgmp.dylib /usr/lib/libgmp.dylib, pero eso tampoco funcionó.

El error es siempre el mismo (ver más abajo) sin importar el ángulo que intente. Cualquier ayuda sería apreciada.

/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

El error cuando intento llamar a Fabric:

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
Author: cosmosis, 2013-03-13

5 answers

Si usas Homebrew, esto debería hacer el truco:

brew install gmp
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto

Usar env garantizará que solo funcione esta vez. Si necesita instalar pycrypto en un momento posterior en otra sesión, exporte la variable en su lugar.

export "CFLAGS=-I/usr/local/include -L/usr/local/lib" 
pip install pycrypto
 53
Author: AKX,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-04 14:21:47

Pude hacer que PyCrypto se instalara usando el siguiente comando:

CFLAGS=-I/opt/local/include pip install pycrypto

Tengo GMP instalado a través de MacPorts, que se ejecuta en OSX 10.8.3 con Python 2.7.2 desde python.org. En este caso estoy instalando en un virtualenv.

Recibo la siguiente advertencia cuando se usa PyCrypto, pero todavía funciona:

/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)
 4
Author: flyingfred0,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-05-06 17:17:57

Simplemente enlazar gmppylib no es útil porque pycrpto necesita compilar algunos archivos C que incluirán gmp.h. Debe tener instalada la biblioteca GMP que contendrá gmp.h. Parece que tienes que instalar GMP en tu Mac OS. Los siguientes dos enlaces deben ser útiles para usted.

 2
Author: Kun Ling,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:24

Finalmente me di cuenta de que la raíz de mi problema estaba en una incompatibilidad entre las versiones de Fabric y Pycrypto. Una vez que bajé mi versión de Fabric a 1.2.6, ya no obtuve los errores anteriores. Luego, usé el tutorial como punto de partida. Sin embargo, a pesar del tutorial y la versión anterior de Fabric, todavía tengo el error PyCrypto >= 2.1, !=2.4. Finalmente instalé Pycrypto 2.2 desde la fuente (ya que aparentemente pip solo instalará v. 2.0.1 incluso al designar pip -Iv install pycrypto==2.2 por esto y v.2.6 resultaron en el error gmp.h). Finalmente, todo funcionó.

 1
Author: cosmosis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 10:31:30

Aquí está la solución que funcionó para mí:

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

Necesita crear un enlace simbólico basado en el encabezado de instalación include path (-I) en but crash. Ejemplo:

Construyendo 'Crypto.PublicKey.extensión _fastmath

/ Applications / Xcode.app / Contents/Developer/Toolchains / XcodeDefault.xctoolchain / usr / bin / clang-fno-strict-aliasing-fno-common-dynamic-pipe-march=native-mmacosx-version-min = 10.7-isysroot /Aplicaciones/Xcode.app / Contents / Developer / Platforms / MacOSX.plataforma/Desarrollador/SDKs/MacOSX10.7.sdk-isystem / Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.plataforma/Desarrollador/SDKs/MacOSX10.7.sdk / usr/include-I/Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.plataforma/Desarrollador/SDKs/MacOSX10.7.sdk / usr/include-I/Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.plataforma/Desarrollador/SDKs/MacOSX10.7.sdk / usr / X11 / include-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.7-x86_64-2.7/src / _fastmath.o

Src/_fastmath.c: 36: 11: error fatal: 'gmp.h ' archivo no encontrado

 0
Author: josephmisiti,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-04-23 15:49:17