安装PySimpleGUI时遭遇SSL证书验证错误,寻求解决方案
解决PySimpleGUI安装时的SSL证书验证失败问题
错误信息
Could not fetch URL https://pypi.org/simple/pysimplegui/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pysimplegui/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))) - skipping Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))) - skipping WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))': /simple/pysimplegui/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))': /simple/pysimplegui/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))': /simple/pysimplegui/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))': /simple/pysimplegui/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)'))': /simple/pysimplegui/ ERROR: Could not find a version that satisfies the requirement PySimpleGUI (from versions: none) ERROR: No matching distribution found for PySimpleGUI
解决方法
临时跳过SSL验证(应急方案,不推荐长期使用)
执行安装命令时添加信任主机参数:pip install PySimpleGUI --trusted-host pypi.org --trusted-host files.pythonhosted.org更新pip到最新版本
旧版pip可能存在SSL兼容性问题,先更新pip:pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org更新完成后再尝试安装PySimpleGUI。
安装/更新系统根证书
系统缺少必要的SSL根证书会导致验证失败,根据你的操作系统执行对应操作:- macOS:打开终端,运行对应Python版本的证书安装脚本(替换X.X为你的Python版本,比如3.10):
/Applications/Python\ 3.10/Install\ Certificates.command - Windows:通过系统设置更新Windows根证书,或者手动安装PyPI网站的SSL根证书。
- Linux(Debian/Ubuntu):安装ca-certificates包并更新证书存储:
sudo apt-get update && sudo apt-get install ca-certificates sudo update-ca-certificates - Linux(CentOS/RHEL):
sudo yum install ca-certificates sudo update-ca-trust extract
- macOS:打开终端,运行对应Python版本的证书安装脚本(替换X.X为你的Python版本,比如3.10):
检查代理设置
如果你的网络使用了代理,代理可能拦截了SSL连接。可以尝试关闭代理后重新安装,或者配置pip使用代理(替换为你的代理地址和端口):pip install PySimpleGUI --proxy http://your-proxy-address:port
内容的提问来源于stack exchange,提问作者Ali Kangooni
相关产品推荐
相关产品推荐

