Error al instalar el paquete de criptografía de Python con PIP y setup.py

Cuando trato de instalar el paquete de criptografía para Python a través de la pip install cryptography o descargando el paquete desde su sitio y ejecutando python setup.py , recibo el siguiente error:


 D:\Anaconda\Scripts\pip-script.py run on 02/27/14 16:13:17 Downloading/unpacking cryptography Getting page https://pypi.python.org/simple/cryptography/ URLs to search for versions for cryptography: * https://pypi.python.org/simple/cryptography/ Analyzing links from page https://pypi.python.org/simple/cryptography/ Skipping https://pypi.python.org/packages/cp26/c/cryptography/cryptography-0.2-cp26-none-win32.whl#md5=13e5c4b19520e7dc6f07c6502b3f74e2 (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp26/c/cryptography/cryptography-0.2.1-cp26-none-win32.whl#md5=00e733648ee5cdb9e58876238b1328f8 (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp27/c/cryptography/cryptography-0.2-cp27-none-win32.whl#md5=013ccafa6a5a3ea92c73f2c1c4879406 (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp27/c/cryptography/cryptography-0.2.1-cp27-none-win32.whl#md5=127d6a5dc687250721f892d55720a06c (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp32/c/cryptography/cryptography-0.2-cp32-none-win32.whl#md5=051424a36e91039807b72f112333ded3 (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp32/c/cryptography/cryptography-0.2.1-cp32-none-win32.whl#md5=53f6f57db8e952d64283baaa14cbde3d (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp33/c/cryptography/cryptography-0.2-cp33-none-win32.whl#md5=302812c1c1a035cf9ba3292f8dbf3f9e (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Skipping https://pypi.python.org/packages/cp33/c/cryptography/cryptography-0.2.1-cp33-none-win32.whl#md5=81acca90caf8a45f2ca73f3f9859fae4 (from https://pypi.python.org/simple/cryptography/) because it is not compatible with this Python Found link https://pypi.python.org/packages/source/c/cryptography/cryptography-0.1.tar.gz#md5=bdc1c5fe069deca7467b71a0cc538f17 (from https://pypi.python.org/simple/cryptography/), version: 0.1 Found link https://pypi.python.org/packages/source/c/cryptography/cryptography-0.2.1.tar.gz#md5=872fc04268dadc66a0305ae5ab1c123b (from https://pypi.python.org/simple/cryptography/), version: 0.2.1 Found link https://pypi.python.org/packages/source/c/cryptography/cryptography-0.2.tar.gz#md5=8a3d21e837a21e1b7634ee1f22b06bb6 (from https://pypi.python.org/simple/cryptography/), version: 0.2 Using version 0.2.1 (newest of versions: 0.2.1, 0.2, 0.1) Downloading from URL https://pypi.python.org/packages/source/c/cryptography/cryptography-0.2.1.tar.gz#md5=872fc04268dadc66a0305ae5ab1c123b (from https://pypi.python.org/simple/cryptography/) Running setup.py (path:c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py) egg_info for package cryptography In file included from c/_cffi_backend.c:7:0: c/misc_win32.h:225:23: error: two or more data types in declaration specifiers c/misc_win32.h:225:1: warning: useless type name in empty declaration [enabled by default] c/_cffi_backend.c: In function 'convert_array_from_object': c/_cffi_backend.c:1105:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1105:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1130:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1130:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1150:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1150:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'convert_struct_from_object': c/_cffi_backend.c:1183:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1183:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1196:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1196:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_repr': c/_cffi_backend.c:1583:13: warning: unknown conversion type character 'L' in format [-Wformat] c/_cffi_backend.c:1583:13: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1595:9: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1595:9: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdataowning_repr': c/_cffi_backend.c:1647:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1647:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function '_cdata_get_indexed_ptr': c/_cffi_backend.c:1820:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1820:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1820:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function '_cdata_getslicearg': c/_cffi_backend.c:1872:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1872:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1872:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_ass_slice': c/_cffi_backend.c:1951:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1951:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1951:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1969:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1969:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1969:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1983:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1983:22: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_call': c/_cffi_backend.c:2367:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2367:30: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2367:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cast_to_integer_or_char': c/_cffi_backend.c:2916:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2916:26: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2916:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:2928:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2928:26: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2928:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'new_array_type': c/_cffi_backend.c:3480:9: warning: unknown conversion type character 'l' in format [-Wformat] c/_cffi_backend.c:3480:9: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'b_complete_struct_or_union': c/_cffi_backend.c:3878:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:3878:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:3878:22: warning: too many arguments for format [-Wformat-extra-args] Traceback (most recent call last): File "", line 17, in  File "c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in  "build": cffi_build, File "D:\Anaconda\lib\distutils\core.py", line 112, in setup _setup_distribution = dist = klass(attrs) File "build\bdist.win-amd64\egg\setuptools\dist.py", line 239, in __init__ File "build\bdist.win-amd64\egg\setuptools\dist.py", line 264, in fetch_build_eggs File "build\bdist.win-amd64\egg\pkg_resources.py", line 580, in resolve dist = best[req.key] = env.best_match(req, ws, installer) File "build\bdist.win-amd64\egg\pkg_resources.py", line 818, in best_match return self.obtain(req, installer) # try and download/install File "build\bdist.win-amd64\egg\pkg_resources.py", line 830, in obtain return installer(requirement) File "build\bdist.win-amd64\egg\setuptools\dist.py", line 314, in fetch_build_egg File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 593, in easy_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in install_item File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 809, in install_eggs File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1015, in build_and_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1003, in run_setup distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1 Complete output from command python setup.py egg_info: In file included from c/_cffi_backend.c:7:0: c/misc_win32.h:225:23: error: two or more data types in declaration specifiers c/misc_win32.h:225:1: warning: useless type name in empty declaration [enabled by default] c/_cffi_backend.c: In function 'convert_array_from_object': c/_cffi_backend.c:1105:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1105:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1130:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1130:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1150:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1150:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'convert_struct_from_object': c/_cffi_backend.c:1183:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1183:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1196:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1196:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_repr': c/_cffi_backend.c:1583:13: warning: unknown conversion type character 'L' in format [-Wformat] c/_cffi_backend.c:1583:13: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1595:9: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1595:9: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdataowning_repr': c/_cffi_backend.c:1647:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1647:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function '_cdata_get_indexed_ptr': c/_cffi_backend.c:1820:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1820:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1820:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function '_cdata_getslicearg': c/_cffi_backend.c:1872:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1872:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1872:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_ass_slice': c/_cffi_backend.c:1951:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1951:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1951:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1969:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1969:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1969:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:1983:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:1983:22: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cdata_call': c/_cffi_backend.c:2367:30: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2367:30: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2367:30: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'cast_to_integer_or_char': c/_cffi_backend.c:2916:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2916:26: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2916:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c:2928:26: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:2928:26: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'Py_ssize_t' [-Wformat] c/_cffi_backend.c:2928:26: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'new_array_type': c/_cffi_backend.c:3480:9: warning: unknown conversion type character 'l' in format [-Wformat] c/_cffi_backend.c:3480:9: warning: too many arguments for format [-Wformat-extra-args] c/_cffi_backend.c: In function 'b_complete_struct_or_union': c/_cffi_backend.c:3878:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:3878:22: warning: unknown conversion type character 'z' in format [-Wformat] c/_cffi_backend.c:3878:22: warning: too many arguments for format [-Wformat-extra-args] Traceback (most recent call last): File "", line 17, in  File "c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in  "build": cffi_build, File "D:\Anaconda\lib\distutils\core.py", line 112, in setup _setup_distribution = dist = klass(attrs) File "build\bdist.win-amd64\egg\setuptools\dist.py", line 239, in __init__ File "build\bdist.win-amd64\egg\setuptools\dist.py", line 264, in fetch_build_eggs File "build\bdist.win-amd64\egg\pkg_resources.py", line 580, in resolve dist = best[req.key] = env.best_match(req, ws, installer) File "build\bdist.win-amd64\egg\pkg_resources.py", line 818, in best_match return self.obtain(req, installer) # try and download/install File "build\bdist.win-amd64\egg\pkg_resources.py", line 830, in obtain return installer(requirement) File "build\bdist.win-amd64\egg\setuptools\dist.py", line 314, in fetch_build_egg File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 593, in easy_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in install_item File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 809, in install_eggs File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1015, in build_and_install File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1003, in run_setup distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1 ---------------------------------------- Cleaning up... Removing temporary dir c:\users\paco\appdata\local\temp\pip_build_Paco... Command python setup.py egg_info failed with error code 1 in c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography Exception information: Traceback (most recent call last): File "D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\basecommand.py", line 122, in main status = self.run(options, args) File "D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\commands\install.py", line 278, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File "D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\req.py", line 1229, in prepare_files req_to_install.run_egg_info() File "D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\req.py", line 325, in run_egg_info command_desc='python setup.py egg_info') File "D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\util.py", line 697, in call_subprocess % (command_desc, proc.returncode, cwd)) InstallationError: Command python setup.py egg_info failed with error code 1 in c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography 

Encontré otros mensajes de error de egg_info ( aquí y aquí ) pero las soluciones que proporcioné no solucionaron mi problema. Además, puedo instalar otros paquetes a través de PIP.

PIP versión 1.5.4 setuptools versión 2.2

Tuve un problema similar y descubrí que simplemente me estaba perdiendo una dependencia (libssl-dev, para mí). Como se menciona en https://cryptography.io/en/latest/installation/ , asegúrese de que se cumplan todas las dependencias:

En Windows

Si estás en Windows, deberás asegurarte de tener OpenSSL instalado. Hay binarios pre-comstackdos disponibles. Si su instalación se encuentra en una ubicación inusual, configure las variables de entorno LIB e INCLUDE para incluir las ubicaciones correspondientes. Por ejemplo:

 C:\> \path\to\vcvarsall.bat x86_amd64 C:\> set LIB=C:\OpenSSL-1.0.1f-64bit\lib;%LIB% C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE% C:\> pip install cryptography 

Construyendo la criptografía en Linux

la criptografía se debe construir muy fácilmente en Linux siempre que tenga un comstackdor de C, encabezados para Python (si no está utilizando pypy) y encabezados para las bibliotecas OpenSSL y libffi disponibles en su sistema.

Para Debian y Ubuntu , el siguiente comando asegurará que las dependencias requeridas estén instaladas:

 sudo apt-get install build-essential libssl-dev libffi-dev python-dev 

Para los derivados de Fedora y RHEL , el siguiente comando garantizará que se instalen las dependencias necesarias:

 sudo yum install gcc libffi-devel python-devel openssl-devel 

Ahora debería poder construir e instalar criptografía con lo habitual.

 pip install cryptography 

Esta es una versión condensada de la información que se encuentra en la página de documentos de instalación de criptografía. Consulta esa página para conocer los últimos detalles.

Como esta pregunta SO sigue apareciendo, también dejaré una respuesta aquí (soy uno de los desarrolladores de pyca / cryptography). Esto es lo que necesita para instalar confiablemente pyca / criptografía en las 3 plataformas principales.

Tenga en cuenta que en todos estos casos, se recomienda encarecidamente que instale en un virtualenv y no en el espacio del paquete global. Esto no es específico de la criptografía, sino que es un consejo genérico para que la instalación de Python sea confiable. El espacio de paquete global en el sistema operativo proporcionado Pythons es propiedad del sistema y la instalación de las cosas a través de pip en él está pidiendo problemas.

Windows

Actualice a la última versión de pip (8.1.2 a partir de junio de 2016) y simplemente pip install cryptography

La criptografía y el cffi se envían como ruedas enlazadas estáticamente.

OS X

Actualice a la última versión de pip (8.1.2 a partir de junio de 2016) y simplemente pip install cryptography

La criptografía y el cffi se envían como ruedas enlazadas estáticamente. Esto funcionará para Pyenv Python, sistema Python, homebrew Python, etc. Mientras estés en la última versión de pip, ni siquiera necesitarás un comstackdor.

Linux

A partir de la versión 2.0, la criptografía incluye ruedas Manylinux1. Esto significa que los usuarios con pip 8.1+ ejecutándose en una distribución basada en glibc (casi todo excepto Alpine Linux) y en x86 / x86-64 (lo siento la gente de Raspberry Pi) ya no necesitan un comstackdor o encabezados porque obtendrás una rueda precomstackda automáticamente . Entonces, lo primero que debes intentar es actualizar tu pip!

Si no eres compatible con manylinux1, esto es lo que debes hacer:

Necesitará un comstackdor de C, libffi + sus encabezados de desarrollo y openssl + sus encabezados de desarrollo.

Debian o distribuciones derivadas de Ubuntu

apt-get install build-essential libssl-dev libffi-dev python-dev seguido de

pip install cryptography

Distribuciones derivadas de Red Hat.

yum install gcc openssl-devel libffi-devel python-devel seguido de

pip install cryptography

Para aquellos de ustedes que ejecutan OS X, esto es lo que funcionó para mí:

 brew install openssl env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography 

(Corriendo 10.9 Mavericks)

También puede intentar fusionar los indicadores y los comandos pip a lo siguiente por el comentario a continuación:

 brew install openssl env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography 

Esto me funcionó en El Capitán.

 brew install pkg-config libffi openssl env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography 

También puede consultar el hilo aquí: https://github.com/pyca/cryptography/issues/2350

Esto solucionó el problema para mí (Ubuntu 16.04):

 sudo apt-get install build-essential libssl-dev libffi-dev python-dev python3-dev 

Y luego funcionaba así:

 pip install cryptography pip install pyopenssl ndg-httpsclient pyasn1 

Al parecer, en las versiones recientes de OSX esto puede deberse a que Apple haya enviado su propia versión de OpenSSL, que no funciona con la biblioteca de criptografía.

Las versiones recientes de la biblioteca de criptografía se envían con sus propias dependencias nativas, pero para obtenerlas necesitará actualizar pip, y posiblemente también env virtual. Así que para mí, la solución fue:

 pip install --upgrade --force-reinstall pip virtualenv 

Cómo resolví “Error en la limpieza del directorio de comstackción para la criptografía”
(Vine aquí de google para obtener este error.)

nota : usando un virtualenv

TL; DR:

mi archivo /etc/apt/sources.list no se configuró correctamente para mi debian 8.

Explicaciones:

Quería instalar paramiko. Paramiko necesita criptografía.

Me dieron estos errores: primero con la pip install cryptography :

 (...) ---------------------------------------- Failed cleaning build dir for cryptography Failed to build cryptography (...) ---------------------------------------- Command "/home/myuser/pyenvs/testo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-HXWKAO/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-WjqY6V-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/myuser/pyenvs/testo/include/site/python2.7/cryptography" failed with error code 1 in /tmp/pip-build-HXWKAO/cryptography/ 

y luego con sudo apt-get install build-essential :

 Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: build-essential : Depends: libc6-dev but it is not going to be installed > or libc-dev Depends: gcc (>= 4:4.4.3) but it is not going to be installed Depends: g++ (>= 4:4.4.3) but it is not going to be installed E: Unable to correct problems, you have held broken packages. 

(No son exactamente los mismos errores que OP, pero estoy aquí para ayudar con el tiempo )

Resolviendo

Después de probar casi todos los comandos de cada publicación, acabo de continuar.
https://wiki.debian.org/SourcesList
y copie mi configuración adecuada en el archivo /etc/apt/sources.list

entonces:

sudo aptitude update

y entonces

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

y entonces

pip install cryptography

hth

Esto me funcionó (estoy usando Ubuntu 14.04):

Primero instale libffi-dev libssl-dev libpython2.7-dev:

 sudo apt-get install libffi-dev libssl-dev libpython2.7-dev 

entonces dentro de virtualenv:

 pip install cryptography pip install pyopenssl ndg-httpsclient pyasn1 

Fuentes:

https://stackoverflow.com/a/32800685/5123544

https://stackoverflow.com/a/29202163/5123544

La respuesta de Nick Woodham no funcionó en OSX 10.11 El Capitán para mí, pero esto sí.

 brew install openssl CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography==0.8 

Probé muchas soluciones arriba, pero solo después de la instalación de la siguiente biblioteca, pude instalar la cryptography :

 sudo apt install libssl1.0 

Estoy usando Ubuntu 18.04

Estaba teniendo problemas con la instalación de cryptography==1.7.1 en Ubuntu 16.04 y ninguna de las respuestas anteriores me ayudó. Entonces, actualicé el requisito a un 1.8.2 compatible y la configuración fue exitosa. Tenga en cuenta que todavía necesitaría elementos esenciales de comstackción y otras dependencias mencionadas en la respuesta superior (la más votada) .

Si está usando python3, necesita instalar python3-dev . Esto solucionó mi problema sudo apt-get install python3-dev .

Estaba teniendo un problema al ejecutar la sudo pip install cryptography porque no encontraba ffi al intentar comstackr. (OSX – Yosemite)

Lo resolví descargando libffi y configurando la env var.

 $ brew install pkg-config libffi $ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/ $ pip install cryptography 

Esto funciona en El Capitán con MacPorts:

 $ sudo port install openssl $ env LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography 

Noté que el póster original estaba claramente usando una instalación de Windows … y las mejores respuestas anteriores son todas para otros sistemas operativos … así que aquí va. Esto supone que ha instalado Python 2.7, que es la versión con mayor compatibilidad (aunque antigua).

  1. Instale el ” Comstackdor de Visual C ++ para Python ”
  2. Abra una ventana de indicador de comando administrativo
  3. Vuelva a ejecutar la instalación de pip (paquete) por ejemplo

     cd C:\Python27\Scripts pip install cryptography (or pycrypto, fabric, etc) 

De hecho, me encontré con este mismo problema al tratar de instalar Scrapy, que depende de la criptografía que se instale primero. Estoy en Win764-bit con Python 2.7 64-bit instalado. La respuesta de @jsonm eventualmente funcionó para mí, pero primero tuve que Copiar C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvarsx86_amd64.bat al x86_amd64 dentro de ese dir. lanzando un error diciendo que faltaba la configuración. If you need to configure env vars for a different setup, be sure to copy to corresponding vcvars bat file to the corresponding subdir or the first command below might not work.

Then I ran the following from a commandline as per @jsonm’s instructions (tweaked for my config)…

 C:\> "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86_amd64 C:\> set LIB=C:\OpenSSL-Win64\lib;%LIB% C:\> set INCLUDE=C:\OpenSSL-Win64\include;%INCLUDE% C:\> pip install cryptography 

Y funcionó.

I had this error too. After continuing to get this error even after installing openSSL, I eventually tried installing from wheel files from https://pypi.python.org/pypi/cryptography/0.2.2#downloads . ¡Funcionó!

i downloaded paramiko full source code from pypi and did

python setup.py install

it worked flawlessly

all default pythondev / openssl /libffi packages are already present in rhel.

downloading rpms have rpm mismatch and more trouble

I encountered a similar issue recently. In my case the versions of cffi and cryptography written in requirements.txt weren’t compatible (cffi==1.8.9 and cryptography==1.9). I solved updating cffi with the last available version.

I am having same problem:

 pip install cryptography . . . Installing collected packages: cffi, cryptography Running setup.py install for cffi ... error 

Then I install libffi-devel and problem is solved

 yum install libffi-devel 

Those two commands fixed it for me:

 brew install openssl brew link openssl --force 

Source: https://github.com/phusion/passenger/issues/1630#issuecomment-147527656

I resolved this by upgrading from cryptography 1.9 to 2.4.2