N'a pas réussi à installer le paquet de cryptographie Python avec PIP et setup.py

quand j'essaie d'installer le paquet cryptographie pour Python par pip install cryptography ou en téléchargeant le paquet de leur site et en lançant python setup.py , j'obtiens l'erreur suivante:


D:AnacondaScriptspip-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:userspacoappdatalocaltemppip_build_Pacocryptographysetup.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 "<string>", line 17, in <module>
      File "c:userspacoappdatalocaltemppip_build_Pacocryptographysetup.py", line 113, in <module>
        "build": cffi_build,
      File "D:Anacondalibdistutilscore.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "buildbdist.win-amd64eggsetuptoolsdist.py", line 239, in __init__
      File "buildbdist.win-amd64eggsetuptoolsdist.py", line 264, in fetch_build_eggs
      File "buildbdist.win-amd64eggpkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "buildbdist.win-amd64eggpkg_resources.py", line 818, in best_match
        return self.obtain(req, installer) # try and download/install
      File "buildbdist.win-amd64eggpkg_resources.py", line 830, in obtain
        return installer(requirement)
      File "buildbdist.win-amd64eggsetuptoolsdist.py", line 314, in fetch_build_egg
      File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 593, in easy_install

      File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 623, in install_item

      File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 809, in install_eggs

      File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 1015, in build_and_install

      File "buildbdist.win-amd64eggsetuptoolscommandeasy_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 "<string>", line 17, in <module>

  File "c:userspacoappdatalocaltemppip_build_Pacocryptographysetup.py", line 113, in <module>

    "build": cffi_build,

  File "D:Anacondalibdistutilscore.py", line 112, in setup

    _setup_distribution = dist = klass(attrs)

  File "buildbdist.win-amd64eggsetuptoolsdist.py", line 239, in __init__

  File "buildbdist.win-amd64eggsetuptoolsdist.py", line 264, in fetch_build_eggs

  File "buildbdist.win-amd64eggpkg_resources.py", line 580, in resolve

    dist = best[req.key] = env.best_match(req, ws, installer)

  File "buildbdist.win-amd64eggpkg_resources.py", line 818, in best_match

    return self.obtain(req, installer) # try and download/install

  File "buildbdist.win-amd64eggpkg_resources.py", line 830, in obtain

    return installer(requirement)

  File "buildbdist.win-amd64eggsetuptoolsdist.py", line 314, in fetch_build_egg

  File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 593, in easy_install



  File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 623, in install_item



  File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 809, in install_eggs



  File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 1015, in build_and_install



  File "buildbdist.win-amd64eggsetuptoolscommandeasy_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:userspacoappdatalocaltemppip_build_Paco...
Command python setup.py egg_info failed with error code 1 in c:userspacoappdatalocaltemppip_build_Pacocryptography
Exception information:
Traceback (most recent call last):
  File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipbasecommand.py", line 122, in main
    status = self.run(options, args)
  File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipcommandsinstall.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipreq.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipreq.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpiputil.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:userspacoappdatalocaltemppip_build_Pacocryptography

j'ai trouvé d'autres messages d'erreur egg_info ( ici et ici ) mais les solutions fournies ne résoudraient pas mon problème. Aussi, je suis possibilité d'installer d'autres paquets via PIP.

PIP version 1.5.4 setuptools version 2.2

226
demandé sur Community 2014-02-27 19:50:27

21 réponses

j'ai eu un problème similaire, et j'ai trouvé que je manquais simplement une dépendance (libssl-dev, pour moi). Comme indiqué dans https://cryptography.io/en/latest/installation / , s'assurer que toutes les dépendances sont respectées:

Sous Windows

si vous êtes sous Windows, vous devez vous assurer que vous avez OpenSSL installé. Des binaires pré-compilés sont disponibles. Si votre installation se trouve à un endroit inhabituel, définissez la LIB et incluez l'environnement les variables à inclure l' emplacements correspondants. Par exemple:

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

cryptographie de bâtiment sur Linux

cryptographie devrait construire très facilement sur Linux à condition que vous avez un compilateur C, en-têtes pour Python (Si vous êtes ne pas utiliser pypy), et les en-têtes pour les bibliothèques OpenSSL et libffi disponibles sur votre système.

pour Debian et Ubuntu , la commande suivante garantira que les les dépendances sont installées:

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

pour Fedora et RHEL-derivatives , la commande suivante assurera que les dépendances requises sont installées:

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

Vous devriez maintenant être en mesure de construire et d'installer la cryptographie avec l'habitude.

pip install cryptography
390
répondu jsonm 2014-03-05 22:01:22

il s'agit d'une version condensée de l'information trouvée sur la page Docs installation de cryptographie. Consulter cette page pour les derniers détails.

puisque cette question n'arrête pas de se poser, je vais laisser tomber une réponse ici aussi (je suis un des développeurs de pyca/cryptographie). Voici ce que vous devez installer de manière fiable pyca/cryptographie sur les 3 plates-formes principales.

s'il vous plaît noter dans tous ces cas, il est fortement recommandé que vous installez dans un virtualenv et non dans l'espace global du paquet. Ce n'est pas spécifique à la cryptographie mais plutôt un conseil générique pour garder votre installation Python fiable. L'espace package global dans OS pourvu que Pythons soit la propriété du système et l'installation de choses via pip dans celui-ci est source de problèmes.

Windows

mise à niveau au dernier pip (8.1.2 à partir de juin 2016) et juste pip install cryptography

cryptographie et cffi sont tous deux expédiés comme roues statiquement liées.

OS X

mise à niveau vers le dernier pip (8.1.2 à partir de juin 2016) et juste pip install cryptography

cryptographie et cffi sont tous deux expédiés comme roues statiquement liées. Cela fonctionne pour pyenv Python, Python système, homebrew Python, etc. Tant que vous utilisez la dernière pip vous n'aurez pas même plus besoin d'un compilateur.

Linux

à partir de la version 2.0 de la cryptographie navires manylinux1 roues. Cela signifie que les utilisateurs avec pip 8.1+ tournant sur une distribution basée sur glibc (presque tout sauf Alpine Linux) et sur x86/x86-64 (désolé les gens de Raspberry Pi) n'ont plus besoin d'un compilateur ou des en-têtes parce que vous obtiendrez une roue précompilée automatiquement. Donc, la première chose que vous devriez essayer est d'améliorer votre pip!

si vous n'êtes pas compatible manylinux1 alors voici ce que vous devez faire:

vous aurez besoin d'un compilateur C, libffi + ses en-têtes de développement, et openssl + ses en-têtes de développement.

distributions dérivées de Debian ou Ubuntu

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

pip install cryptography

Red Hat distributions dérivées de

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

pip install cryptography

93
répondu Paul Kehrer 2017-07-20 07:07:50

pour ceux d'entre vous qui utilisez OS X, voici ce qui a fonctionné pour moi:

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

(Course 10.9 Mavericks)

vous pouvez également essayer de fusionner les drapeaux et les commandes pip à ce qui suit selon le commentaire ci-dessous:

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
40
répondu Nick Woodhams 2016-01-28 04:44:56

cela a fonctionné pour moi à El Capitan

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

vous pouvez aussi vérifier le fil ici: https://github.com/pyca/cryptography/issues/2350

22
répondu Dean Christian Armada 2016-03-05 04:16:26

cela a résolu le problème pour moi (Ubuntu 16.04):

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

et puis ça marchait comme ça:

pip install cryptography
pip install pyopenssl ndg-httpsclient pyasn1
20
répondu alneven 2017-05-01 18:27:33

apparemment sur les versions récentes D'OSX cela peut être causé par Apple expédition leur propre version D'OpenSSL, qui ne fonctionne pas avec la bibliothèque de cryptographie.

versions récentes du navire de bibliothèque de cryptographie avec leurs propres dépendances natives, mais pour les obtenir, vous aurez besoin de mettre à niveau pip, et éventuellement aussi env virtuel. Donc pour moi, la solution était:

pip install --upgrade --force-reinstall pip virtualenv
14
répondu Cam Jackson 2016-03-08 12:37:15

Comment j'ai résolu "Échec de nettoyage construire dir pour la cryptographie"

(Je suis venu ici à partir de google à la suite de cette erreur.)

note : en utilisant un virtualenv

TL; DR:

mon fichier /etc/apt/sources.list n'était pas correctement configuré pour debian 8.

explications:

je voulais installer paramiko. paramiko a besoin de cryptographie.

j'ai eu ces erreurs: d'abord avec 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/

et ensuite avec 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.

(pas exactement les mêmes erreurs que OP mais je suis ici pour aider éventuellement )

résolution:

après avoir testé presque toutes les commandes de chaque poste je finis par aller sur

https://wiki.debian.org/SourcesList

et copié collé ma configuration adéquate dans le fichier /etc/apt/sources.list

puis:

sudo aptitude update

puis

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

puis

pip install cryptography

hth

14
répondu Boop 2016-08-19 17:18:22

cela a fonctionné pour moi (j'utilise Ubuntu 14.04):

première installation libffi-dev libssl-dev libpython2.7-dev:

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

puis dans virtualenv:

pip install cryptography
pip install pyopenssl ndg-httpsclient pyasn1

Sources:

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

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

9
répondu akashbw 2017-05-23 12:10:45

la réponse de Nick Woodham ne marchait pas sur OSX 10.11 El Capitan pour moi, mais ça marchait.

brew install openssl
CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography==0.8
7
répondu ouroboros 2015-12-02 13:25:34

j'avais un problème avec sudo pip install cryptography parce qu'il ne trouvait pas ffi lors de la compilation. (OSX - Yosemite)

Je l'ai résolu en téléchargeant libffi et en mettant en place l'env var.

$ brew install pkg-config libffi
$ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig/
$ pip install cryptography
3
répondu ThinkBonobo 2015-10-21 14:50:59

Si vous utilisez python3, vous devez installer python3-dev . Cela a corrigé mon problème sudo apt-get install python3-dev .

3
répondu Pobe 2016-09-12 20:03:42

cela fonctionne sur El Capitan avec MacPorts:

$ sudo port install openssl
$ env LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
3
répondu Torsten Homberger 2016-09-27 10:12:22

j'avais des problèmes avec l'installation de cryptography==1.7.1 sur Ubuntu 16.04 et aucune des réponses ci-dessus n'a aidé. Ainsi, j'ai mis à jour l'exigence à un compatible 1.8.2 et la configuration a été réussie. Notez que vous auriez tout de même besoin de construire l'essentiel et d'autres dépendances mentionnées dans la réponse acceptée.

2
répondu shad0w_wa1k3r 2017-09-28 09:31:34

j'ai en fait rencontré ce même prob essayant d'installer Scrapy qui dépend de la cryptographie étant installé en premier. Je suis sur Win764 bits avec Python 2.7 64 bits installé. la réponse de @jsonm a finalement fonctionné pour moi, mais d'abord j'ai dû copier C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvarsx86_amd64.bat dans le sous-DIR x86_amd64 dans ce bin dir pour que le vcvarsall.bat cesse de lancer une erreur disant qu'il manquait la config. Si vous avez besoin de configurer envvars pour une configuration différente, assurez-vous de copier dans le fichier bat vcvars correspondant pour le sous-DIR correspondant ou la première commande ci-dessous pourrait ne pas fonctionner.

puis j'ai lancé ce qui suit depuis une ligne de commande selon les instructions de @jsonm (modifié pour ma configuration)...

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

et ça a marché.

1
répondu minorgod 2014-04-28 00:09:15

j'ai eu cette erreur aussi. Après avoir continué à obtenir cette erreur, même après avoir installé openSSL, j'ai finalement essayé d'installer à partir des fichiers de roue de https://pypi.python.org/pypi/cryptography/0.2.2#downloads . Il a travaillé!

1
répondu user3357177 2014-05-29 20:41:57

j'ai remarqué que l'affiche originale utilisait clairement une installation windows... et les meilleures réponses ci-dessus sont toutes pour D'autres OSs... donc, ici, va. Cela suppose que vous avez installé Python 2.7 qui est la version la plus largement supportée (bien qu'ancienne).

  1. Installer " Compilateur Visual C++ pour Python "
  2. ouvrir une fenêtre d'invite de commande Administrative
  3. redémarrer pip install (colis) p.ex.

    cd C:\Python27\Scripts
    pip install cryptography  (or pycrypto, fabric, etc)
    
1
répondu Steven the Easily Amused 2016-05-09 22:05:56

j'ai téléchargé le code source complet de paramiko à partir de pypi et j'ai fait

python setup.py installer

cela a parfaitement fonctionné

tous les paquets pythondev / openssl /libffi par défaut sont déjà présents dans rhel.

le téléchargement de rpms a des problèmes de vitesse et plus

1
répondu RICHA AGGARWAL 2016-10-19 07:54:42

j'ai rencontré un problème similaire récemment. Dans mon cas, les versions de cffi et cryptography écrites dans les exigences.txt n'était pas compatible (cffi==1.8.9 et cryptographie==1.9). J'ai résolu la mise à jour cffi avec la dernière version disponible.

1
répondu Griffosx 2017-07-06 20:31:17

j'ai le même problème:

pip install cryptography

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

puis j'installe libffi-devel et le problème est résolu

yum install libffi-devel
0
répondu Pradip Das 2016-05-04 03:49:00

ces deux commandes l'ont fixé pour moi:

brew install openssl
brew link openssl --force

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

0
répondu Tobias Lorenz 2016-06-12 17:14:07

j'ai essayé beaucoup de solutions ci-dessus, mais seulement après l'installation de la lib suivante j'ai pu installer cryptography :

sudo apt install libssl1.0

j'utilise Ubuntu 18.04

0
répondu Daniil Mashkin 2018-08-16 09:42:51