如何通过带有配置脚本的公司代理使用 pip 安装软件包?



我无法使用pip安装任何软件包。我在使用代理脚本配置的公司代理后面。代理文件采用维基百科上描述的格式。

操作系统: 视窗 10 企业版 64 位
Python 版本: 3.7.4
点版本: 19.0.3

在阅读了有关stackoverflow的各种其他问题之后,我测试了不同类型的选项,其中一些会导致不同的错误:

  1. 没有额外的选项:
pip install scipy --verbose
Collecting scipy
1 location(s) to search for versions of scipy:
* https://pypi.org/simple/scipy/
Getting page https://pypi.org/simple/scipy/
Looking up "https://pypi.org/simple/scipy/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Incremented Retry for (url='/simple/scipy/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x068AD410>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/scipy/
  1. 将代理设置为指向配置文件:
pip install scipy --verbose --proxy http://<redacted>.com/proxy.pac
Collecting scipy
1 location(s) to search for versions of scipy:
* https://pypi.org/simple/scipy/
Getting page https://pypi.org/simple/scipy/
Looking up "https://pypi.org/simple/scipy/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Incremented Retry for (url='/simple/scipy/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)'))': /simple/scipy/
  1. 设置受信任的主机,例如此处的建议
pip install scipy --proxy http://<redacted>.com/proxy.pac --verbose --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org

。让我在尝试 2 中得到与之前相同的结果。如何进行?SSL错误很奇怪,我不知道下一步该怎么做。

所以,我在问之前解决了这个问题。解决方案很简单:

从 proxy.pac 文件中获取第一个(默认)代理,并将其用作 pip 代理选项的输入。

最新更新