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

yos*_*sra 9 python ssl pip

我收到此错误:

由于 EnvironmentError 无法安装软件包:找不到合适的 TLS CA 证书包,路径无效:/home/yosra/Desktop/CERT.RSA

当我运行时: $ virtualenv venv

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

我得到了这个:

由于 EnvironmentError 无法安装软件包:HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /KristianOellegaard/django-hvad/archive/2.0.0-beta.tar.gz (Caused通过 SSLError(SSLError(0, '未知错误 (_ssl.c:3715)'),))

我觉得这两个错误相互关联,但我想知道如何修复第一个错误?

xxk*_*kkk 11

如果您使用的是 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
Run Code Online (Sandbox Code Playgroud)

然后做修改.bashrc

export REQUESTS_CA_BUNDLE="$HOME/.mac-ca-roots"
Run Code Online (Sandbox Code Playgroud)

然后做

$ source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)


Anu*_*raz 11

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

python -c "import certifi; print(certifi.where())"
Run Code Online (Sandbox Code Playgroud)

然后先手动测试一下;

pip install -r requirements.txt --cert=<the above certificate path>
Run Code Online (Sandbox Code Playgroud)

如果工作正常,则更新位于 $HOME/.pip/pip.conf(或 Windows 上的 %APPDATA%\pip\pip.ini)的 pip.conf 文件上的此路径。例如

[global]
cert = /usr/local/share/ca-certificate/mycert.crt
Run Code Online (Sandbox Code Playgroud)


小智 6

在 Windows 10 中, 1. 使用以下命令找到 certifi 的位置以检查是否已安装

import certifi
certifi.where()
Run Code Online (Sandbox Code Playgroud)
  1. 记下 cacert.pem 文件的路径

  2. 在 windows 资源管理器中搜索 pip.ini 文件并在记事本中编辑该文件并设置 path = <file path of cacert.pem >

  • 通过运行命令“pip config -v list”查找所有可能的“pip.ini”文件 (3认同)

小智 5

修复 Windows 10,

遇到的错误:error: could not install packages due to an oserror: could not find a suitable tls ca certificate bundle, invalid path: c:\program files\postgresql\16\ssl\certs\ca-bundle.crt 。使用 pip 安装新包时遇到。

原因:postgresql 安装以某种方式更新了系统环境变量。

分两步修复(对我有用):

  1. 使用 中存在的路径 更新系统环境CURL_CA_BUNDLE变量 。注意添加完整路径,在我的例子中cacert.pemPython311\Lib\site-packages\pip\_vendor\certifi\cacert.pemC:\Program Files\Python311\Lib\site-packages\pip\_vendor\certifi\cacert.pem
  2. 重新启动电脑