安装Python模块遇TLS CA证书路径错误,求解决方法
解决pip安装Python模块的TLS CA证书路径错误
ERROR: Could not install packages due to an OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /path/to/cacert.pem
WARNING: There was an error checking the latest version of pip.
确认证书路径有效性
检查/path/to/cacert.pem是否为真实存在的文件路径,若路径错误,替换为实际证书文件的正确路径。安装时指定证书路径
安装模块时通过--cert参数指定有效证书:pip install 目标模块名 --cert /实际路径/cacert.pem若需永久生效,设置环境变量:
# Linux/macOS终端 export PIP_CERT=/实际路径/cacert.pem # Windows命令提示符 set PIP_CERT=C:\实际路径\cacert.pem # Windows PowerShell $env:PIP_CERT = "C:\实际路径\cacert.pem"修复或重新安装pip
尝试更新pip以修复配置异常:python -m ensurepip --upgrade若无效,用脚本重新安装pip(需指定有效证书):
curl https://bootstrap.pypa.io/get-pip.py | python - --cert /实际路径/cacert.pem切换为系统默认CA证书
若无需自定义证书,取消PIP_CERT环境变量,让pip使用系统默认证书:# Linux/macOS unset PIP_CERT # Windows命令提示符 set PIP_CERT= # Windows PowerShell Remove-Item Env:PIP_CERT
内容的提问来源于stack exchange,提问作者bb aa
相关产品推荐
相关产品推荐

