python - 如何使用配置脚本通过企业代理使用 pip 安装软件包?

标签 python ssl pip

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

操作系统:Windows 10 企业版 64 位
Python版本:3.7.4
pip 版本: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. 按照建议设置可信主机,例如 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/

相关文章:

Python3 virtualenv 安装失败 : No module named 'virtualenv.seed.via_app_data'

python - ' | ' python 集合对象之间的运算符

python - Azure Functions for python、结构化日志记录到 Application Insights?

svn SSL 错误 : certificate verify failed?

android - 使用 Google Cloud Endpoints 时如何避免中间人攻击?

python - Docker 无法找到满足要求的版本 mysqlclient == 2.0.3

python - 没有进度条的 pip 安装

python - Pandas - 将两列转换为一个新列作为字典

python - mrjob:无效的引导操作路径,必须是 Amazon S3 中的一个位置

ssl - 哪些 TLS/SSL 密码套件被认为是弱/强?