首页 > 解决方案 > Python 3.7:将代理应用于 pip 安装的所有部分,无法维护代理变量

问题描述

我有以下问题,我正在使用命令

pip install pyinstaller --proxy=http://webdefence.global.blackspider.com:80 --trusted-host=pypi.python.org

我遇到的问题是代理变量没有通过安装过程维护。尝试安装 setuptools 时,它不再具有代理地址。我试过在我的环境变量中使用HTTP_PROXYand ,但没有成功。HTTPS_PROXY还有其他方法可以设置将通过 pip 安装维护的代理吗?

我使用 -vvv 来生成更多错误细节 - 粘贴在 gist.github.com/blaggrob/19e7afcae2b4f1d36139fbf0a88a6651

Collecting pyinstaller
  Using cached https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz
  Installing build dependencies ... error
  Complete output from command c:\users\blaggr\appdata\local\programs\python\python37-32\scripts\python.exe -m pip install --ignore-installed --no-user --prefix C:\Users\blaggr\AppData\Local\Temp\pip-build-env-vd3w15r1 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --trusted-host pypi.python.org -- setuptools wheel:
  Collecting setuptools
    Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/setuptools/
    Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/setuptools/
    Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/setuptools/
    Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/setuptools/
    Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/setuptools/
    Could not find a version that satisfies the requirement setuptools (from versions: )
  No matching distribution found for setuptools

标签: pythonpip

解决方案


您可能遇到了新的PEP 518 支持实现的错误,其中为安装构建时依赖项而创建的隔离构建环境缺少必要的代理配置。

--no-build-isolation您可以通过在命令行中使用、no-build-isolation=no在配置文件中设置或通过设置环境变量来绕过新功能PIP_NO_BUILD_ISOLATION=no(是的,最后两个选项是违反直觉的)。

这确实需要,setuptools然后wheels在您可以安装之前已经安装pyinstaller

我已经向该项目提交了一个新问题pip来跟踪这个问题,我不相信它以前曾被报道过。


推荐阅读