无法使用PIP和setup.py安装Python加密包
当我尝试通过pip install cryptography
安装Cryptography软件包或从他们的站点下载软件包并运行python setup.py
,出现以下错误:
D:AnacondaScriptspip-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:userspacoappdatalocaltemppip_build_Pacocryptographysetup.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 "<string>", line 17, in <module>
File "c:userspacoappdatalocaltemppip_build_Pacocryptographysetup.py", line 113, in <module>
"build": cffi_build,
File "D:Anacondalibdistutilscore.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 239, in __init__
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 264, in fetch_build_eggs
File "buildbdist.win-amd64eggpkg_resources.py", line 580, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "buildbdist.win-amd64eggpkg_resources.py", line 818, in best_match
return self.obtain(req, installer) # try and download/install
File "buildbdist.win-amd64eggpkg_resources.py", line 830, in obtain
return installer(requirement)
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 314, in fetch_build_egg
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 593, in easy_install
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 623, in install_item
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 809, in install_eggs
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 1015, in build_and_install
File "buildbdist.win-amd64eggsetuptoolscommandeasy_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 "<string>", line 17, in <module>
File "c:userspacoappdatalocaltemppip_build_Pacocryptographysetup.py", line 113, in <module>
"build": cffi_build,
File "D:Anacondalibdistutilscore.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 239, in __init__
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 264, in fetch_build_eggs
File "buildbdist.win-amd64eggpkg_resources.py", line 580, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "buildbdist.win-amd64eggpkg_resources.py", line 818, in best_match
return self.obtain(req, installer) # try and download/install
File "buildbdist.win-amd64eggpkg_resources.py", line 830, in obtain
return installer(requirement)
File "buildbdist.win-amd64eggsetuptoolsdist.py", line 314, in fetch_build_egg
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 593, in easy_install
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 623, in install_item
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 809, in install_eggs
File "buildbdist.win-amd64eggsetuptoolscommandeasy_install.py", line 1015, in build_and_install
File "buildbdist.win-amd64eggsetuptoolscommandeasy_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:userspacoappdatalocaltemppip_build_Paco...
Command python setup.py egg_info failed with error code 1 in c:userspacoappdatalocaltemppip_build_Pacocryptography
Exception information:
Traceback (most recent call last):
File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipbasecommand.py", line 122, in main
status = self.run(options, args)
File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipcommandsinstall.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipreq.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpipreq.py", line 325, in run_egg_info
command_desc='python setup.py egg_info')
File "D:Anacondalibsite-packagespip-1.5.4-py2.7.eggpiputil.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:userspacoappdatalocaltemppip_build_Pacocryptography
我发现其他egg_info错误帖子(这里和这里),但提供的解决方案不会解决我的问题。 另外,我可以通过PIP安装其他软件包。
PIP版本1.5.4 setuptools版本2.2
我有一个类似的问题,并发现我只是错过了依赖(libssl-dev,对我来说)。 如https://cryptography.io/en/latest/installation/中所述,确保符合所有依赖关系:
在Windows上
如果你在Windows上,你需要确保你已经安装了OpenSSL。 有预编译的二进制文件可用。 如果您的安装位于不常见的位置,请将LIB和INCLUDE环境变量设置为包含相应的位置。 例如:
C:> pathtovcvarsall.bat x86_amd64
C:> set LIB=C:OpenSSL-1.0.1f-64bitlib;%LIB%
C:> set INCLUDE=C:OpenSSL-1.0.1f-64bitinclude;%INCLUDE%
C:> pip install cryptography
在Linux上构建密码学
如果您有一个C编译器,Python的头文件(如果您不使用pypy)以及系统上可用的OpenSSL和libffi库的头文件,则加密应该在Linux上非常容易地构建。
对于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
这是密码学安装文档页面上的精简版信息。 请参阅该页面了解最新的细节。
由于这个SO问题不断出现,我也会在这里放弃一个响应(我是pyca /加密开发人员之一)。 这就是你需要在三大平台上可靠地安装pyca / cryptography。
请注意,在所有这些情况下, 强烈建议您安装到virtualenv中,而不是安装到全局程序包空间中。 这不是特定于密码学,而是通用建议,以保持您的Python安装可靠。 在OS提供的全局包空间中,Pythons由系统所有,并通过点到点安装,这是在寻求麻烦。
视窗
升级到最新的点子(截至2016年6月8.1.2),只需pip install cryptography
密码学和cffi都作为静态链接轮出货。
OS X
升级到最新的点子(截至2016年6月8.1.2),只需pip install cryptography
密码学和cffi都作为静态链接轮出货。 这将适用于pyenv Python,系统Python,自制Python等。只要你在最新的点子上,你甚至不需要编译器。
Linux的
从版本2.0开始,密码系统会运送manylinux1轮子。 这意味着使用基于glibc的发行版(几乎除Alpine Linux之外的所有产品)以及x86 / x86-64(对不起Raspberry Pi的用户)运行基于glibc的发行版的用户不再需要编译器或头文件,因为您将自动获得预编译轮。 所以,你应该尝试的第一件事是升级你的点子!
如果你不是manylinux1兼容,那么你需要做的是:
你需要一个C编译器,libffi +的开发头文件,以及openssl +的开发头文件。
Debian或Ubuntu派生的发行版
apt-get install build-essential libssl-dev libffi-dev python-dev
后面跟着
pip install cryptography
红帽派生的分布
yum install gcc openssl-devel libffi-devel python-devel
后面跟着
pip install cryptography
对于那些运行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小牛)
您可能还想尝试将标志和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
链接地址: http://www.djcxy.com/p/26311.html
上一篇: Failed to install Python Cryptography package with PIP and setup.py