当我试图通过pip install cryptography
或通过从their site下载包并运行python setup.py
来安装Python的Cryptography包时,出现以下错误:
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 "<string>", line 17, in <module>
File "c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in <module>
"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 "<string>", line 17, in <module>
File "c:\users\paco\appdata\local\temp\pip_build_Paco\cryptography\setup.py", line 113, in <module>
"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\req.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\req.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错误帖子(here和here),但是那里提供的解决方案并不能解决我的问题。另外,我还可以通过PIP安装其他软件包。
PIP版本1.5.4 setuptools版本2.2
我有一个类似的问题,发现我只是缺少依赖性(libssl dev,对我来说)。如https://cryptography.io/en/latest/installation/所述,确保满足所有依赖性:
在Windows上
如果您在Windows上,则需要确保已安装OpenSSL。有预编译的二进制文件可用。如果您的安装位置不寻常,请设置LIB和INCLUDE环境变量以包括 相应的位置。例如:
在Linux上构建加密系统
如果你有一个C编译器,Python的头文件(如果你是 不使用pypy),以及系统上可用的OpenSSL和libffi库的头。
对于Debian和Ubuntu,以下命令将确保安装所需的依赖项:
对于Fedora和RHEL衍生物,以下命令将确保安装所需的依赖项:
现在您应该可以用通常的方法构建和安装加密。
对于那些运行OSX的人来说,以下是对我有用的:
(运行10.9小牛)
您还可以尝试根据下面的注释将标志和pip命令合并到以下内容:
这是在密码学的installation文档页上找到的信息的压缩版本。有关最新详细信息,请参阅该页。
由于这个问题不断出现,我也会在这里放弃回答(我是pyca/密码技术开发人员之一)。下面是在3个主要平台上可靠安装pyca/加密技术所需要的。
请注意,在所有这些情况下,强烈建议您安装到virtualenv而不是全局包空间中。这并不是特定于加密技术,而是保持Python安装可靠的一般建议。操作系统提供的Pythons中的全局包空间归系统所有,通过pip安装东西会带来麻烦。
窗口
升级至最新pip(截至2016年6月的8.1.2版本),只需
pip install cryptography
密码学和cffi都是以静态链接的方式提供的。
操作系统X
升级至最新pip(截至2016年6月的8.1.2版本),只需
pip install cryptography
密码学和cffi都是以静态链接的方式提供的。这将适用于pyenv Python、系统Python、自制Python等。只要使用最新的pip,您甚至不需要编译器。
Linux
从2.0版起,密码学将提供manylinux1轮子。这意味着使用pip 8.1+的用户在基于glibc的发行版(除了Alpine Linux之外几乎所有的发行版)和x86/x86-64(对不起,Raspberry Pi用户)上运行时不再需要编译器或头文件,因为您将自动获得预编译的控制盘。所以,首先你应该尝试升级你的pip!
如果您不兼容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
相关问题 更多 >
编程相关推荐