python - 如何通过带有配置脚本的公司代理使用 pip 安装软件包?
问题描述
我无法使用 pip 安装任何软件包。我支持使用代理脚本配置的公司代理。代理文件采用Wikipedia 上描述的格式。
操作系统:Windows 10 Enterprise 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/
- 按照建议设置受信任的主机,例如这里
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 代理选项的输入。
推荐阅读
- linux - 解决我必须删除大小为 0 的文件的 shell 脚本?
- python - Python ValueError: x and y must be the same size and X[:, 0] Y[:] not working to save the problem
- regex - 给出一个匹配这个正则表达式的字符串?
- python - 无法使用python将数据存储在文件中
- node.js - 尝试使用 nodeJS mongodb 模块连接到本地 MongoDB 服务器时出错
- c++ - 使用命令行参数 argv[] 创建同名数据文件
- django - 为什么我的序列化程序测试给我一个“TypeError:'ReturnDict'对象不可调用”错误?
- python-3.x - 为什么 or-combined != 有时不符合预期
- android - android是否有检查推送通知的时间周期?
- python - Linkedin刮刀提取技能