我无法使用 pip 安装任何软件包。我在使用代理脚本配置的公司代理后面。代理文件采用描述的格式 on Wikipedia .
操作系统:Windows 10 企业版 64 位
Python版本:3.7.4
pip 版本:19.0.3
在阅读了 stackoverflow 上的各种其他问题后,我测试了不同类型的选项,其中一些会导致不同的错误:
- 没有额外的选项:
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/
- 将代理设置为指向配置文件:
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/
- 按照建议设置可信主机,例如 here
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 代理选项的输入。
关于python - 如何使用配置脚本通过企业代理使用 pip 安装软件包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57496413/