使用pip安装Levenshtein时遇SSL证书验证失败错误求助
解决pip安装Levenshtein时的SSL证书验证失败问题
错误信息
ERROR: Could not install packages due to an OSError:
HTTPSConnectionPool(host='files.pythonhosted.org', port=443):
Max retries exceeded with url:
/packages/7b/be/21ea38c3d63a1345a338c495ebe7c29c1e5fa915d4a7b71a7b25117a1d10/Levenshtein-0.20.5-cp310-cp310-win_amd64.whl
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
self signed certificate in certificate chain (_ssl.c:997)')))
解决方法
临时跳过SSL验证(仅临时使用)
执行命令:pip install levenshtein --trusted-host pypi.org --trusted-host files.pythonhosted.org该命令指定信任PyPI的核心域名,临时绕过证书验证。
永久配置pip信任域名
创建或修改pip配置文件:- Windows:路径为
%APPDATA%\pip\pip.ini - Linux/macOS:路径为
~/.config/pip/pip.conf
在文件中添加以下内容:
[global] trusted-host = pypi.org files.pythonhosted.org保存后重新执行
pip install levenshtein即可。- Windows:路径为
更新系统根证书
- Windows:打开「Internet选项」→「内容」→「证书」,导入缺失的根证书;或通过Windows更新安装最新证书包。
- Linux(Ubuntu/Debian):执行
sudo apt update && sudo apt install ca-certificates - Linux(CentOS/RHEL):执行
sudo yum update ca-certificates - macOS:打开「钥匙串访问」,将缺失证书添加到系统信任区;或执行
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /path/to/your/certificate.crt(替换证书实际路径)。
使用国内PyPI镜像源
国内镜像源通常无证书问题,且下载速度更快,执行命令:pip install levenshtein -i https://mirrors.aliyun.com/pypi/simple/
内容的提问来源于stack exchange,提问作者Pauli du Plooy
相关产品推荐
相关产品推荐

