【问题标题】:How can I make PyCharm ignore SSL errors when installing libraries?如何让 PyC​​harm 在安装库时忽略 SSL 错误?
【发布时间】:2018-07-15 14:35:31
【问题描述】:

我正在尝试在使用自签名 SSL 证书的公司网络上将requests 库安装到我在 PyCharm 中的 Python 环境中。因此,使用 File > Settings > Project > Project Interpreter > Install 安装库失败并出现 HTTPS 错误:

Collecting requests
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection
    broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.
    VerifiedHTTPSConnection object at 0x0368D5D0>: Failed to establish a new connection:
    [Errno 11003] getaddrinfo failed',)': /simple/requests/
  Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests

我尝试通过在我的安装选项中添加--cert C:\COMPANY-CAROOT.pem 来使pip 信任我公司的根证书,这被解释为:

pip install --cert C:\COMPANY-CAROOT.pem requests

我也尝试打开 File &gt; Settings &gt; Project &gt; Server Certificates 并检查自动接受不受信任的证书,但遇到了同样的问题。

如何让 PyC​​harm 在安装外部库时忽略 SSL 证书错误?

【问题讨论】:

    标签: python pip pycharm ssl-certificate


    【解决方案1】:

    我遇到了同样的问题。我解决它的方法是将我想要安装的所有软件包添加到 .txt 文件中,例如requirements.txt 包含所有包名及其版本。

    然后从终端(也可以是 PyCharm 终端),我做了:

    pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt
    

    这里的关键是--trusted-host的使用。在文件中添加包只是为了方便。 或者,您可以创建一个pip.ini 文件并在其中添加受信任的主机。

    【讨论】:

      猜你喜欢
      • 2021-01-29
      • 2015-12-16
      • 1970-01-01
      • 2019-03-20
      • 2016-11-09
      • 2020-01-27
      • 2018-11-09
      • 2013-09-26
      • 1970-01-01
      相关资源
      最近更新 更多