【问题标题】:How to install cryptography on ubuntu?如何在 ubuntu 上安装密码学?
【发布时间】:2016-05-10 17:33:33
【问题描述】:

我的 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

我不知道为什么它失败了。是什么原因。在ubuntu系统上安装有什么必要的吗?

【问题讨论】:

  • 请阅读文档的 Linux 部分:cryptography.io/en/latest/installation
  • @KlausD。谢谢你。我没有仔细检查文件。在我安装了必要的 ubuntu 软件包后,我可以成功安装密码学。但是当我尝试在 Mac OS X 上安装它时,也出现了错误:cffi.ffiplatform.VerificationError: CompileError: command 'clang' failed with exit status 1。由于我的系统,我认为这次很特别。
  • 这应该是一个新问题或谷歌查询。
  • @KlausD。是的,我会发布一个新问题。非常感谢你。如果你喜欢在这里写答案,我会接受。
  • @ithelloworld 请考虑“接受” - 回答。

标签: python ubuntu cryptography pip


【解决方案1】:

答案在 cryptography's installation section 的文档中,这几乎反映了 Angelos 的答案:

引用它:

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

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

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

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

您现在应该能够使用 平常的

$ pip install cryptography

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

如果您在 Ubuntu 18.04 上安装它,请在第一个命令中使用 libssl1.0 而不是 libssl-dev。 (感谢@pobe)

【讨论】:

  • 如果你使用的是 python3,你还需要 python3-dev。所以 sudo apt-get install python3-dev
  • Ubuntu 18.04 : apt install libssl1.0,我花了很长时间才找到它。
  • @Pobe 谢谢!!!我花了 forever 才发现:P 我创建了一个单独的问题,希望能帮助未来的人们:stackoverflow.com/questions/57684081
  • @Pobe - 谢谢!我花了太长时间试图弄清楚我需要安装 libssl1.0。
  • @chasmani:我已将您的回复包含在您的回复中,以便更容易找到。谢谢。
【解决方案2】:

在 ubuntu 16.04 上安装 libssl-dev 和 python-dev 对我来说已经足够了。

【讨论】:

  • 你能弄明白吗?
【解决方案3】:

在 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

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

apt-get install -y libssl-dev

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2017-12-18
    相关资源
    最近更新 更多