Windows系统PyCharm 2023.3.5无法安装第三方包求助
SSL证书验证失败导致PyCharm无法安装第三方包(pandas、openpyxl等)
环境信息
- 系统:Windows 64位
- Python版本:3.11.0
- PyCharm版本:Community Edition 2023.3.5
报错信息
无法获取URL https://pypi.org/simple/openpyxl/: 确认SSL证书时出现问题: HTTPSConnectionPool(host='pypi.org', port=443): 对URL /simple/openpyxl/ 的重试次数已达上限 (由SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)')) 引起) - 跳过 无法获取URL https://pypi.org/simple/pip/: 确认SSL证书时出现问题: HTTPSConnectionPool(host='pypi.org', port=443): 对URL /simple/pip/ 的重试次数已达上限 (由SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)')) 引起) - 跳过
警告: 连接被 'SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)'))' 中断后重试 (Retry(total=4, connect=None, read=None, redirect=None, status=None)): /simple/openpyxl/ 警告: 连接被 'SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)'))' 中断后重试 (Retry(total=3, connect=None, read=None, redirect=None, status=None)): /simple/openpyxl/ 警告: 连接被 'SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)'))' 中断后重试 (Retry(total=2, connect=None, read=None, redirect=None, status=None)): /simple/openpyxl/ 警告: 连接被 'SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)'))' 中断后重试 (Retry(total=1, connect=None, read=None, redirect=None, status=None)): /simple/openpyxl/ 警告: 连接被 'SSLError(SSLCertVerificationError(1, '[SSL: 证书验证失败] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:992)'))' 中断后重试 (Retry(total=0, connect=None, read=None, redirect=None, status=None)): /simple/openpyxl/ 错误: 找不到满足要求 openpyxl==3.2.0b1 的版本 (可用版本: 无) 错误: 没有找到匹配 openpyxl==3.2.0b1 的发行版
解决方案
方法1:安装时指定国内镜像源
在PyCharm包安装界面添加国内镜像参数:
- 打开
File > Settings > Project: [你的项目名] > Python Interpreter - 点击右上角
+号,搜索目标包(如openpyxl) - 在
Install Package窗口的Options输入框中填入:-i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn - 点击
Install Package完成安装
方法2:配置全局pip镜像源
- 在Windows用户目录(如
C:\Users\你的用户名)新建pip文件夹 - 文件夹内创建
pip.ini文件,写入以下内容:[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple trusted-host = pypi.tuna.tsinghua.edu.cn - 重启PyCharm后重新尝试安装包
方法3:更换稳定版包安装
报错提示找不到openpyxl==3.2.0b1(beta测试版),可直接搜索openpyxl安装最新稳定版,避免指定测试版本导致的匹配失败。
方法4:更新系统SSL证书
- 下载最新的根证书文件
- 找到Python安装目录下的
Lib\site-packages\certifi文件夹,替换其中的cacert.pem文件为新证书 - 重启PyCharm后重试安装
内容的提问来源于stack exchange,提问作者RXXX
相关产品推荐
相关产品推荐

