Python 如何在ubuntu上安装加密?

Python 如何在ubuntu上安装加密?,python,ubuntu,cryptography,pip,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'

我的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
安装egg脚本。
使用命名空间包,但发行版不需要setuptools。
正在获取“加密==0.2.1”的分发。
未找到与“documentation/\u build”匹配的以前包含的目录
未设置zip_安全标志;正在分析存档内容。。。
六:模块引用路径__
已安装/tmp/easy_install-oUz7ei/cryptography-0.2.1/.eggs/six-1.10.0-py2.7.egg
搜索cffi>=0.8
阅读https://pypi.python.org/simple/cffi/
最佳匹配:cffi 1.5.0
正在下载https://pypi.python.org/packages/source/c/cffi/cffi-1.5.0.tar.gz#md5=dec8441e67880494ee881305059af656
加工cffi-1.5.0.tar.gz
正在编写/tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/setup.cfg
运行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:致命错误:ffi.h:没有这样的文件或目录
#包括
^
编译终止。
错误:安装程序脚本退出,出现错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为1
尝试安装加密0.2.1时出错。查看此消息上方的easy_install输出的任何错误。
而:
安装egg脚本。
正在获取“加密==0.2.1”的分发。
错误:无法安装:加密0.2.1

我不知道为什么失败了。原因是什么。在ubuntu系统上安装加密模块时,有必要做些什么吗?

我在ubuntu 14.04上安装加密模块时遇到了同样的问题。我通过安装libffi dev解决了这个问题:

apt-get install -y libffi-dev
然后我得到了以下错误:

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

答案在
密码学
的文档中,这几乎反映了Angelos的答案:

引用它:

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

$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
$ sudo yum install gcc libffi-devel python-devel openssl-devel
对于Fedora和RHEL衍生物,以下命令将确保 已安装所需的依赖项:

$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
$ sudo yum install gcc libffi-devel python-devel openssl-devel
现在,您应该能够使用 平常的

如果您使用的是Python 3,请在第一个命令中使用
python3-dev
而不是
Python-dev
。(感谢@chasmani)


如果您在
ubuntu18.04
上安装此软件,请在第一个命令中使用
libssl1.0
而不是
libssl dev
。(感谢@pobe)

在ubuntu 16.04上安装libssl-dev和python-dev就足够了。

请阅读文档的Linux部分:@klauds。非常感谢。我没有仔细检查文件。在我安装了必要的ubuntu软件包之后,我可以成功地安装加密。但当我尝试在Mac OS X上安装它时,也出现了一个错误:
cffi.ffiplate.VerificationError:CompileError:command'clang'失败,退出状态为1
。由于我的系统,我认为这次很特别。这应该是一个新问题或谷歌查询。是的,我将发布一个新问题。非常感谢。如果你想在这里写下答案,我会接受它。@ IsChalWord请考虑“ACCEP”-一个答案。如果你使用Python 3,你也需要Python 3 DEV。所以sudo apt get install python3 devUbuntu 18.04:apt install libssl1.0,我花了很长时间才找到它。@Pobe谢谢!!!我花了很长时间才发现:P我创建了一个单独的问题,希望能帮助未来的人们:@Pobe-谢谢!我花了太长时间试图弄清楚我需要安装libssl1.0。@chasmani:我已经在你的回复中加入了,以便更容易找到。谢谢,你能弄明白吗?