python安装setup failed_无法使用PIP和setup.py安装Python Cryptography包

当我尝试通过pip install cryptography安装Python的Cryptography包或从他们的站点下载包并运行python setup.py时,我收到以下错误:

D:\Anaconda\Scripts\pip-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:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.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"", line 17, in

File"c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in

"build": cffi_build,

File"D:\Anaconda\lib\distutils\core.py", line 112, in setup

_setup_distribution = dist = klass(attrs)

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 239, in __init__

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 264, in fetch_build_eggs

File"build\bdist.win-amd64\egg\pkg_resources.py", line 580, in resolve

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

File"build\bdist.win-amd64\egg\pkg_resources.py", line 818, in best_match

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

File"build\bdist.win-amd64\egg\pkg_resources.py", line 830, in obtain

return installer(requirement)

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 314, in fetch_build_egg

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 593, in easy_install

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in install_item

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 809, in install_eggs

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1015, in build_and_install

File"build\bdist.win-amd64\egg\setuptools\command\easy_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"", line 17, in

File"c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in

"build": cffi_build,

File"D:\Anaconda\lib\distutils\core.py", line 112, in setup

_setup_distribution = dist = klass(attrs)

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 239, in __init__

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 264, in fetch_build_eggs

File"build\bdist.win-amd64\egg\pkg_resources.py", line 580, in resolve

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

File"build\bdist.win-amd64\egg\pkg_resources.py", line 818, in best_match

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

File"build\bdist.win-amd64\egg\pkg_resources.py", line 830, in obtain

return installer(requirement)

File"build\bdist.win-amd64\egg\setuptools\dist.py", line 314, in fetch_build_egg

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 593, in easy_install

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 623, in install_item

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 809, in install_eggs

File"build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1015, in build_and_install

File"build\bdist.win-amd64\egg\setuptools\command\easy_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:\users\paco\appdata\local\temp\pip_build_Paco...

Command python setup.py egg_info failed with error code 1 in c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography

Exception information:

Traceback (most recent call last):

File"D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\basecommand.py", line 122, in main

status = self.run(options, args)

File"D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\commands\install.py", line 278, in run

requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)

File"D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip

eq.py", line 1229, in prepare_files

req_to_install.run_egg_info()

File"D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip

eq.py", line 325, in run_egg_info

command_desc='python setup.py egg_info')

File"D:\Anaconda\lib\site-packages\pip-1.5.4-py2.7.egg\pip\util.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:\users\paco\appdata\local\temp\pip_build_Paco\cryptography

我发现了其他egg_info错误帖子(这里和这里),但那里提供的解决方案无法解决我的问题。 此外,我可以通过PIP安装其他软件包。

PIP版本1.5.4 setuptools版本2.2

我有一个类似的问题,发现我只是缺少一个依赖(libssl-dev,对我而言)。如https://cryptography.io/en/latest/installation/中所述,请确保满足所有依赖性:

在Windows上

如果您使用的是Windows,则需要确保已安装OpenSSL。有预编译的二进制文件可用。如果您的安装位于异常位置,请将LIB和INCLUDE环境变量设置为包含

相应的位置。例如:

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

在Linux上构建加密技术

如果你有一个C编译器,Python的头文件(如果你的话),那么加密应该很容易在Linux上构建

不使用pypy),以及系统上可用的OpenSSL和libffi库的标头。

对于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

谢谢,完美地工作!拥有VS2010我不得不:设置VS90COMNTOOLS =%VS100COMNTOOLS%并为lib名称添加"mt"后缀

//,我可以确认这在使用Python 3.3的CEntOS 6.3机器上工作,但与原始问题中发布的错误类似。

似乎libffi-dev包是关键所在。我不需要再配置任何东西,但是这个包名没有出现在错误日志中: - /谢谢。

在尝试pip安装bcrypt时,这个(特别是libssl-dev步骤)解决了我的问题。非常感谢!

这在CentOS7上对我有用 - 谢谢!

如果您使用的是python3,请不要忘记将python-dev替换为python3-dev

谢谢。曾在Linux Mint(Serena)工作。

@duan我应该在哪里用python-dev3更改python-dev。实际上我面临着与AWS linux相同的问题。我问过问题链接,但直到现在才得到答案。

@RajuSingh在apt-get install命令中

@duan好的。我没有使用ubuntu。我在aws -linux服务器上运行该命令。你能指导我这个问题吗?

FWIW我正在运行Debian 9并且必须先执行apt-get install libssl1.0-dev才能在pip安装加密期间退出错误

这是在加密的安装文档页面上找到的信息的精简版本。有关最新详细信息,请参阅该页面。

由于这个SO问题不断出现,我也会在这里删除一个响应(我是pyca /加密开发人员之一)。以下是在3个主要平台上可靠地安装pyca / cryptography所需的内容。

请注意,在所有这些情况下,强烈建议您安装到virtualenv而不是全局包空间。这不是特定于加密,而是保持Python安装可靠的通用建议。操作系统中的全局程序包空间提供了Pythons由系统拥有,并通过pip安装东西就是在寻找麻烦。

视窗

升级到最新的点子(截至2016年6月的8.1.2),只需pip install cryptography

密码学和cffi都作为静态链接轮运输。

OS X.

升级到最新的点子(截至2016年6月的8.1.2),只需pip install cryptography

密码学和cffi都作为静态链接轮运输。这适用于pyenv Python,系统Python,自制Python等。只要您使用的是最新的pip,您甚至不需要编译器。

Linux的

从版本2.0开始,加密manylinux1轮子。这意味着在基于glibc的发行版(几乎所有除Alpine Linux之外的所有内容)和x86 / x86-64(抱歉Raspberry Pi人)上运行的pip 8.1+的用户不再需要编译器或头文件,因为您将自动获得预编译的轮子。所以,首先你应该尝试升级你的点子!

如果你不是manylinux1兼容,那么这就是你需要做的:

你需要一个C编译器,libffi +它的开发头文件,以及openssl +它的开发头文件。

Debian或Ubuntu派生的发行版

apt-get install build-essential libssl-dev libffi-dev python-dev接着是

pip install cryptography

Red Hat派生的发行版

yum install gcc openssl-devel libffi-devel python-devel接着是

pip install cryptography

我已经完成了这个,但我仍然得到这个错误:"失败的构建轮子加密"后面跟着很多输出(评论太多了)。

MacOSX响应就像MacOS Sierra 10.12上的魅力一样。我已经将我的点数升级到此时的最新版本9.0.1。

升级到最新的pip(截至2016年6月的8.1.2),只需pip安装加密工作!

我不得不手动更新我已经很久的pip,然后OSX解决方案就像魅力一样。 (pip 9.0.1,MacOS Sierra)

pip可以用(sudo) pip install --upgrade pip升级自己

适用于Red Hat派生的发行版!谢谢保罗

在Fedora上安装--user标志不起作用。必须以root身份安装才能绕过错误。

不能在我的windows10上运行,得到构建错误无法打开包含文件:'openssl / opensslv.h'

它在Ubuntu 16.04中对我不起作用

对于那些运行OS X的人来说,这对我有用:

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

(跑10.9小牛队)

您可能还想根据以下注释尝试将flags和pip命令合并到以下内容:

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

来自reaperhulk的CFLAGS="-I/usr/include" pip install cryptography在小牛队为我工作。

答案中的此命令不正确:必须合并第二行和第三行(使用反斜杠)。然后它完美地工作,刚刚在El Capitan上测试过。以上评论也不正确。答案中的其他设置是必要的,否则您将得到以后的投诉。

一如既往@nathancahill HEHE

我必须使用export而不是env,否则可以使用。

当需要cryptography以便安装ansible时,$ ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography在macOS 10.12上使用Python3.7(在virtualenv中)为我工作。

这解决了我的问题(Ubuntu 16.04):

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

然后它的工作方式如下:

pip install cryptography

pip install pyopenssl ndg-httpsclient pyasn1

这对El Capitan来说很有用

brew install pkg-config libffi openssl

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

您还可以在此处查看该主题:https://github.com/pyca/cryptography/issues/2350

也为Sierra工作

我是如何解决"为加密清理构建目录失败"的

(我是从谷歌来到这里导致此错误。)

注意:使用virtualenv

TL; DR:

我的文件/etc/apt/sources.list没有为我的debian 8正确配置。

说明:

我想安装paramiko。

paramiko需要密码学。

我收到了这些错误:

首先使用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('

', '

'), __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/

然后用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.

(与OP不完全相同的错误,但我最终会在这里提供帮助)

解决:

在对每个帖子中的几乎所有命令进行测试之后,我最终还是继续进

https://wiki.debian.org/SourcesList

并在文件/etc/apt/sources.list中复制粘贴我的足够配置

然后:

sudo aptitude update

然后

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

然后

pip install cryptography

心连心

解决了我在ubuntu 16.04服务器上的问题。谢谢

显然,在最新版本的OSX上,这可能是因为Apple发布了自己的OpenSSL版本,而这些版本不适用于加密库。

最新版本的加密库附带了自己的本机依赖项,??但要获得它们,您需要升级pip,还可能需要虚拟环境。所以对我来说,解决方案是:

pip install --upgrade --force-reinstall pip virtualenv

virtualenv重新安装为我做了它,它使用的旧版本的pip一直在失败,谢谢!

对我来说仍然失败。 OSX 10.11.3 El Capitan在这里。

也适用于RedHat。

我上面尝试了很多解决方案,但只有在安装了以下lib之后我才能安装cryptography:

sudo apt install libssl1.0

我正在使用Ubuntu 18.04,但它也适用于Ubuntu 18.10。

虽然此代码可以回答这个问题,但提供有关如何和/或解决问题的原因的其他背景将提高答案的长期价值。

这对我有用。它为什么有效?安装libssl1.0-dev和libssl-dev的软件包有什么区别?

我不明白为什么,但只有这对我有帮助

我不知道为什么。但这解决了

只有这解决了我的问题Ubuntu 18.04

这对我有用(我使用的是Ubuntu 14.04):

首先安装libffi-dev libssl-dev libpython2.7-dev:

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

然后在virtualenv内:

pip install cryptography

pip install pyopenssl ndg-httpsclient pyasn1

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值