Python pip install之SSL异常处理操作


Posted in Python onSeptember 03, 2020

异常内容:

C:\Users\ccwant>pip install requests
Collecting requests
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/requests/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/requests/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/requests/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/requests/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)': /simple/requests/
Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),)) - skipping
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests

处理办法:

打开以下目录,并创建pip文件夹

C:\Users\用户\AppData\Roaming

进入pip文件夹,创建pip.ini文件,内容如下

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

此配置的作用是修改pip的安装源,此处修改为阿里的源,然后使用pip install安装就不会报错了

补充知识:处理Python3中使用pip install时提示"SSL: CERTIFICATE_VERIFY_FAILED"

CentOS7使用官方yum源安装了Python3和pip(yum搜不到python3的话请安装epel-release)

[root@client0 yum.repos.d]# python3 --version
Python 3.6.8
[root@client0 yum.repos.d]# pip3 --version
pip 8.1.2 from /usr/lib/python3.6/site-packages (python 3.6)

使用pip安装包时会提示你pip版本过低, 建议使用pip install --upgrade pip命令来升级.

而使用该命令时则会弹出一连串错误提示, 其中包含关键字"SSL: CERTIFICATE_VERIFY_FAILED"

这时的处理办法是跳过pip的SSL验证

使用命令

pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>

即可.

以上这篇Python pip install之SSL异常处理操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python多线程同步Lock、RLock、Semaphore、Event实例
Nov 21 Python
python 查找字符串是否存在实例详解
Jan 20 Python
python+opencv实现高斯平滑滤波
Jul 21 Python
Python设计模式之解释器模式原理与用法实例分析
Jan 10 Python
python中的单引号双引号区别知识点总结
Jun 23 Python
Django组件content-type使用方法详解
Jul 19 Python
PyQt5+Pycharm安装和配置图文教程详解
Mar 24 Python
超全Python图像处理讲解(多模块实现)
Apr 13 Python
使用Keras中的ImageDataGenerator进行批次读图方式
Jun 17 Python
Django跨域请求原理及实现代码
Nov 14 Python
用python对excel进行操作(读,写,修改)
Dec 25 Python
python 爬取腾讯视频评论的实现步骤
Feb 18 Python
详解python tkinter 图片插入问题
Sep 03 #Python
解决PyCharm IDE环境下,执行unittest不生成测试报告的问题
Sep 03 #Python
PyTorch中Tensor的数据类型和运算的使用
Sep 03 #Python
python开发入门——set的使用
Sep 03 #Python
使用anaconda安装pytorch的实现步骤
Sep 03 #Python
解决Python安装cryptography报错问题
Sep 03 #Python
解决python打开https出现certificate verify failed的问题
Sep 03 #Python
You might like
PHP下用rmdir实现删除目录的三种方法小结
2008/04/20 PHP
laravel实现分页样式替换示例代码(增加首、尾页)
2017/09/22 PHP
Ubuntu中支持PHP5与PHP7双版本的简单实现
2018/08/19 PHP
jquery中对于批量deferred的处理方法
2014/01/22 Javascript
jQuery scroll事件实现监控滚动条分页示例
2014/04/04 Javascript
JavaScript中document.forms[0]与getElementByName区别
2015/01/21 Javascript
JavaScript实现简单的二级导航菜单实例
2015/04/15 Javascript
JavaScript+CSS实现仿天猫侧边网页菜单效果
2015/08/25 Javascript
jQuery+CSS3实现四种应用广泛的导航条制作实例详解
2016/09/17 Javascript
javascript另类方法实现htmlencode()与htmldecode()函数实例分析
2016/11/17 Javascript
Javascript中 带名 匿名 箭头函数的重要区别(推荐)
2017/01/29 Javascript
vue指令以及dom操作详解
2017/03/04 Javascript
使用 Vue.js 仿百度搜索框的实例代码
2017/05/09 Javascript
jQuery简单绑定单个事件的方法示例
2017/06/10 jQuery
JS倒计时实例_天时分秒
2017/08/22 Javascript
vue滑动吸顶及锚点定位的示例代码
2020/05/10 Javascript
Javascript基于OOP实实现探测器功能代码实例
2020/08/26 Javascript
Vue 禁用浏览器的前进后退操作
2020/09/04 Javascript
vue使用echarts实现水平柱形图实例
2020/09/09 Javascript
win7 下搭建sublime的python开发环境的配置方法
2014/06/18 Python
Python Matplotlib库入门指南
2015/05/18 Python
Python程序中用csv模块来操作csv文件的基本使用教程
2016/03/03 Python
Python 编码规范(Google Python Style Guide)
2018/05/05 Python
tensorflow更改变量的值实例
2018/07/30 Python
详解Django的model查询操作与查询性能优化
2018/10/16 Python
Python 微信之获取好友昵称并制作wordcloud的实例
2019/02/21 Python
Python2与Python3的区别实例分析
2019/04/11 Python
CSS3 渐变(Gradients)之CSS3 线性渐变
2016/07/08 HTML / CSS
Foot Locker德国官方网站:美国运动服和鞋类零售商
2018/11/01 全球购物
波兰品牌鞋履在线商店:Eastend.pl
2020/01/11 全球购物
优秀教师事迹简介
2014/02/02 职场文书
商业活动邀请函
2014/02/04 职场文书
物流毕业生个人的自我评价
2014/02/13 职场文书
应届生面试求职信
2014/07/02 职场文书
2014物价局群众路线对照检查材料思想汇报
2014/09/21 职场文书
县长群众路线对照检查材料思想汇报
2014/10/02 职场文书