如何在ubuntu上安装加密?

ith*_*rld 68 python ubuntu cryptography pip

我的ubuntu是14.04 LTS.

当我安装加密时,错误是:

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
Run Code Online (Sandbox Code Playgroud)

我不知道为什么失败了.是什么原因.在ubuntu系统上安装时是否有必要?

kmo*_*oor 126

答案是对的文档cryptography安装部分,这几乎反映了Angelos的回答:

引用它:

对于Debian和Ubuntu,以下命令将确保安装所需的依赖项:

$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Run Code Online (Sandbox Code Playgroud)

对于Fedora和RHEL衍生产品,以下命令将确保安装所需的依赖项:

$ sudo yum install gcc libffi-devel python-devel openssl-devel
Run Code Online (Sandbox Code Playgroud)

您现在应该能够使用通常的方式构建和安装加密

$ pip install cryptography
Run Code Online (Sandbox Code Playgroud)

  • 如果你使用的是python3,你还需要python3-dev.所以sudo apt-get install python3-dev (5认同)
  • Ubuntu 18.04:** apt install libssl1.0 **,让我永远找不到它。 (2认同)

Ang*_*los 48

当在Ubuntu 14.04上安装加密模块时,我遇到了同样的问题.我通过安装libffi-dev解​​决了这个问题:

apt-get install -y libffi-dev
Run Code Online (Sandbox Code Playgroud)

然后我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

我通过安装libssl-dev解​​决了这个问题:

apt-get install -y libssl-dev
Run Code Online (Sandbox Code Playgroud)