WARNING: Retrying (Retry(total=4, connect=None,...after connection broken by ‘SSLError(SSLEOFError

WARNING: Retrying (Retry(total=4, connect=None,...after connection broken by ‘SSLError(SSLEOFError

1. 故障描述

问题:在使用python时,我们经常需要安装一些包,但是在终端prompt或者cmd界面下,使用pip install xxx(包)的时候,可能会出现如下的报错信息:

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/bista/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/bista/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/bista/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/bista/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/bista/
Could not fetch URL https://pypi.org/simple/bista/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/bista/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement bista (from versions: none)
ERROR: No matching distribution found for bista

**问题原因:**pip源由于国内、国外墙的原因,连接证书验证失败。

2. 永久解决源和信任问题

2.1 Windows下指定源并信任

  • 找到系统盘下C:\Users\用户名\AppData\Roaming

  • 查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个;

  • 进入pip文件夹,创建一个pip.ini文件;

  • 使用记事本的方式打开pip.ini文件,写入:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple  # 指定下载源
trusted-host = mirrors.aliyun.com             # 指定域名

2.2 Ubuntu下指定源并信任

找到~/.pip/pip.conf,如果不存在就创建,加入内容如下

cd ~/.pip/pip.conf

写入下述代码

[global]
timeout = 10 # 设置超时,单位s
index-url =  http://mirrors.aliyun.com/pypi/simple/   # 指定优先下载源
extra-index-url= http://pypi.douban.com/simple/   # 第二下载源
[install]
trusted-host=
    mirrors.aliyun.com
    pypi.douban.com
    pypi.tuna.tsinghua.edu.cn

3. 代码式问题解决

这个需要每次在pip install xxx(包)之后加一串信任和源名称的代码,相对来说较为直截了当。
调用国内的源镜像,并信任指定的源
国内的pip源:

  • 阿里云 http://mirrors.aliyun.com/pypi/simple/
  • 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  • 豆瓣(douban) http://pypi.douban.com/simple/
  • 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
  • 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

标准示意代码如下:

pip install xxx -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
  • 8
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cnjs1994

你的鼓励将是我最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值