使用pip安装模块时,出现错误Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None))

曾经终败给现在 2023-02-12 08:28 110阅读 0赞

问题:

学习python,使用pip安装各种模块时出错,出错信息:

  1. WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, stonnection broken
  2. by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:operation timed out'))': /simple/pylint/

解决方法:

出现该错误信息是因为pip源连接证书验证失败,将pip源调整为国内的源就可以了,比如要下载pylint

  1. pip install pylint -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

如果想要永久修改pip源,可按照如下操作:

Windows

  1. 找到系统盘下C:\C:\Users\用户名\AppData\Roaming
  2. 查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个;
  3. 进入pip文件夹,创建一个pip.ini文件;
  4. 使用记事本的方式打开pip.ini文件,写入:

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

    如图:20200525160043202.png

Linux:

  1. # 找到~/.pip/pip.conf,如果不存在就创建,加入内容如下:
  2. [global]
  3. timeout = 10 # 设置超时,单位s
  4. index-url = http://mirrors.aliyun.com/pypi/simple/ # 指定优先下载源
  5. extra-index-url= http://pypi.douban.com/simple/ # 第二下载源
  6. [install]
  7. trusted-host=
  8. mirrors.aliyun.com
  9. pypi.douban.com

下面是收集的一些国内的pip源:

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

发表评论

表情:
评论列表 (有 0 条评论,110人围观)

还没有评论,来说两句吧...

相关阅读