web-dev-qa-db-fra.com

Comment installer la cryptographie sur Ubuntu?

Mon Ubuntu est 14.04 LTS.

Lorsque j'installe la cryptographie, l'erreur est la suivante:

Installing Egg-scripts.
uses namespace packages but the distribution does not require setuptools.
Getting distribution for 'cryptography==0.2.1'.

no previously-included directories found matching 'documentation/_build'
Zip_safe flag not set; analyzing archive contents...
six: module references __path__

Installed /tmp/easy_install-oUz7ei/cryptography-0.2.1/.eggs/six-1.10.0-py2.7.Egg
Searching for cffi>=0.8
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 1.5.0
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.5.0.tar.gz#md5=dec8441e67880494ee881305059af656
Processing cffi-1.5.0.tar.gz
Writing /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/setup.cfg
Running cffi-1.5.0/setup.py -q bdist_Egg --dist-dir /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/Egg-dist-tmp-A2kjMD
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
 #include <ffi.h>
                 ^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
An error occurred when trying to install cryptography 0.2.1. Look above this message for any errors that were output by easy_install.
While:
  Installing Egg-scripts.
  Getting distribution for 'cryptography==0.2.1'.
Error: Couldn't install: cryptography 0.2.1

Je ne sais pas pourquoi cela a échoué. Quelle est la raison. Y at-il quelque chose de nécessaire lors de l’installation sur le système Ubuntu?

67
ithelloworld

La réponse se trouve dans la documentation de cryptography ' section d'installation , ce qui correspond assez bien à la réponse d'Angelos:

En le citant:

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

$ Sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Pour Fedora et les dérivés RHEL, la commande suivante s'assurera que les dépendances requises sont installées:

$ Sudo yum install gcc libffi-devel python-devel openssl-devel

Vous devriez maintenant pouvoir construire et installer la cryptographie avec les fonctions habituelles.

$ pip install cryptography
124
kmonsoor

J'ai eu le même problème lorsque pip installant le module de cryptographie sur Ubuntu 14.04. Je l'ai résolu en installant libffi-dev:

apt-get install -y libffi-dev

Ensuite, j'ai eu l'erreur suivante:

build/temp.linux-x86_64-3.4/_openssl.c:431:25: fatal error: openssl/aes.h: No such file or directory
 #include <openssl/aes.h>
                         ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Ce que j'ai résolu en installant libssl-dev:

apt-get install -y libssl-dev
48
Angelos

Installer libssl-dev et python-dev me suffisait pour Ubuntu 16.04.

1
Renato Prado