pip安装报错There was a problem confirming the ssl certificate【已解决】

pip安装报错There was a problem confirming the ssl certificate

错误提示

Could not fetch URL https://pypi.org/simple/tensorflow/: There was a problem confirming the ssl certificate: HTTPSCo
nnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/tensorflow/ (Caused by SSLError("Can
't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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("Can't connect to HTT
PS URL because the SSL module is not available.")) - skipping

解决方法
创建pip配置pip.ini

(1)在系统目录C:\Users\用户\AppData\Roaming新建pip文件夹;

(2)在pip文件夹下新建pip.ini文件,并写入如下配置:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
这个错误通常意味着你的Python环境无法SSL证书,可能是由于缺少或损的根证书文件导致的。你尝试以下方法来解决这个问题: . 更新pip:首先尝试更新pip本身,因为旧版本的pip可能法正确处理SSL证书。行以下命令来: ``` python -m pip install --upgrade pip ``` 2. 重新安装根证书:下载最新的根证书文件(如cacert.pem)并保存到你的计算机上,例如保存到C:\路径下。 3. 设置环变量:设置一个名为 `REQUESTS_CA_BUNDLE` 的环境变量,并将其值设置为根证书文件的路径,例如 C:\cacert.pem。这将告诉Python在安装包时使用指定的根证书文件来验证SSL连接。 在Windows上,你可以按照以下步骤设置环境变量: - 右键点击 "此电脑" 或 "我的电脑",选择 "属性"。 - 点击 "高级系统设置"。 - 在 "系统属性" 窗口中,点击 "环境变量" 按钮。 - 在 "环境变量" 窗口中,点击 "新建"。 - 输入变量名 `REQUESTS_CA_BUNDLE`,输入变量值为根证书文件的完整路径(例如 C:\cacert.pem)。 - 点击 "确定" 保存设置。 4. 重启终端或编辑器:如果你是在终端或编辑器中运行Python命令,尝试重新启动它们,以便它们可以加载新的环境变量。 尝试以上方法后,再次运行pip安装命令来安装所需的包,应该就能够成功验证SSL证书并完成安装。如果问题仍然存在,请确保你的计算机可以正常访问互联网,并检查网络连接和防火墙设置。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值