令狐少侠 发表于 2018-9-20 14:59:22

distutils.errors.DistutilsError: Setup script exited with error: command 'gcc...

当我尝试通过其中任何一个或通过从他们的站点下载包并运行来安装Python 的Cryptography包时,我收到以下错误:pip install cryptographypython setup.py
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 = 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
我可以通过PIP安装其他软件包。
PIP版本1.5.4 setuptools版本2.2

他改变了中国 发表于 2018-9-20 15:00:38

我有一个类似的问题,发现我只是缺少一个依赖(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的头文件(如果你没有使用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

强人锁男 发表于 2018-9-20 15:02:25

这是在Cryptography的安装文档页面上找到的信息的精简版本。有关最新详细信息,请参阅该页面。
由于这个SO问题不断出现,我也会在这里删除一个响应(我是pyca /Cryptography开发人员之一)。以下是在3个主要平台上可靠地安装pyca / cryptography所需的内容。
请注意,在所有这些情况下,强烈建议你安装到virtualenv而不是全局包空间。这不是特定于Cryptography的,而是保持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开始,Cryptographymanylinux1轮子。这意味着在基于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

德国骨科 发表于 2018-9-20 15:07:58

对于那些运行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
你可能还想根据以下注释尝试将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

天使与魔鬼 发表于 2018-9-20 15:08:40

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

页: [1]
查看完整版本: distutils.errors.DistutilsError: Setup script exited with error: command 'gcc...