由于环境环境无法安装包装:找不到合适的TLS CA证书bundle,无效的路径



我得到此错误:

由于环境环境无法安装软件包:找不到合适的TLS CA证书捆绑包,无效的路径:/home/yosra/desktop/cert.rsa

当我运行时:$ virtualenv venv

所以我在桌面上放了一个随机的cert.rsa,并创建了我的虚拟环境,但是当我运行时: pip install -r requirements.txt

我得到了这个:

由于环境环境:httpsconnectionpool(host ='github.com',port = 443(无法安装软件包:用URL超过的最大重试gz(由sslerror引起(sslerror(0,'未知错误(_ssl.c:3715('(,((

我觉得这两个错误彼此链接,但是我想知道如何修复第一个错误?

如果您在Mac上(我的是10.13.6(,请使用以下命令:

(security find-certificate -a -p ls /System/Library/Keychains/SystemRootCertificates.keychain &&        security find-certificate -a -p ls /Library/Keychains/System.keychain) > $HOME/.mac-ca-roots

然后用

修改.bashrc
export REQUESTS_CA_BUNDLE="$HOME/.mac-ca-roots"

然后做

$ source ~/.bashrc

在Windows 10中1.找到带有以下命令的认证位置,以检查是否已安装

import certifi
certifi.where()
  1. 记下cacert.pem文件的路径

  2. 在Windows Explorer中搜索pip.ini文件,并在记事本中编辑文件,并设置path = <file path of cacert.pem >

您需要允许PIP引用正确的证书。首先检查证书;

python -c "import certifi; print(certifi.where())"

然后首先手动测试;

pip install -r requirements.txt --cert=<the above certificate path>

如果工作正常,请在$ home/.pip/.pip/pip.conf上更新此路径(或Windows上的%appdata% pip pip.ini(。例如

[global]
cert = /usr/local/share/ca-certificate/mycert.crt

我在运行命令时收到了此错误。在pycharm。

如果您查看错误,您会发现错误指出了" packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle -- Invalid path&quot。

我通过删除环境变量解决了这一问题。REQUESTS_CA_BUNDLE或者,您可以更改环境变量的名称。REQUESTS_CA_BUNDLE&quot还有其他名称。

重新启动您的pycharm,应该解决此问题。

谢谢!

旧文章。但是,为我的未来自我和其他陷入困境的人回答!

首先找到pip.conf(linux(:

[root@localhost ~]# pip3 config -v list
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/root/.pip/pip.conf'
For variant 'user', will try loading '/root/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'

如果尚未存在,那么您可以在这些位置中的任何一个中创建pip.conf文件(这也对虚拟env有效(。参考。https://pip.pypa.io/en/stable/cli/pip_config/#cmdoption-user用于变体规范。

然后将下面的源添加到pip.conf文件:

trusted-host = pypi.org
               pypi.python.org
               pypi.org
               pypi.co
               files.pythonhosted.org
               pip.pypa.io

保存并按照pip安装或照常下载。

要查找证书,安装认证并在以下代码下运行:

[root@localhost ~]# python3 -c "import certifi; print(certifi.where())"
/usr/local/lib/python3.6/site-packages/certifi/cacert.pem

我们一直在为各种'git'动作进行此操作。我们有自己的CA 中介机构,我们不够自定义我们的软件安装以适应这一事实。

我们的通用修复程序是通过串联或更换使用CA CERT PEM更新您的ca-bundle.crt

例如。cat my_cert_chain.pem >> $(python -c "import certifi; print(certifi.where())")

如果您有/etc/pki/tls/certs目录,则可以很好地工作,但是使用Python python -c "import certifi; print(certifi.where())"告诉您Python的Ca-bundle.crt文件的位置。

尽管这不是纯粹的python答案,因为我们没有添加新的文件/路径,因此当您了解基本问题时,它可以解决其他软件的其他证书问题。

我建议在这种情况下进行连接,因为我不知道该文件用于vis-a-vis pypi。

最新更新