Python安装、更新,第三方库时遇到:WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None···

前言

使用Python的小伙伴避免不了安装各种第三方库,时长会出现命令输入正确,却无法完成安装,找了很多种方法都无法解决,为此我整理了几种方式,希望可以帮到你。

错误信息

安装或更新第三方库时报错详细信息:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProxyError(‘Cannot connect to proxy.’, OSError(0, ‘Error’))’: /simple/zipp/

出现问题的原因

引起安装失败的原因是由于pip的库是Python自带的,安装较慢或者服务链接不顺畅,导致执行命令是无法找到该第三方库。修改pip引用的镜像地址即可。国内镜像地址在文章尾部,请自取。

方式一:

不更改镜像地址,单个第三方库安装命令

#在命令执行窗输入:
pip install Pyinstaller -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

(其中的Pyinstaller 是你需要下载的库或包名,根据自己需求自行更改即可)

方式二:

  • 将镜像地址修改未阿里云http://mirrors.aliyun.com/pypi/simple/
  • 找到路径:C:\Users\dxy\AppData\Roaming
  • Roaming路径下有个pip文件夹,将pip文件夹中的pip.ini文件修改为阿里镜像地址
  • #如果Roaming路径下没有pip文件夹或pip文件夹下没有pip.ini文件,可自己创建
    [global]
    index-url = http://mirrors.aliyun.com/pypi/simple  
    trusted-host = mirrors.aliyun.com
    
    

    配置完成后,重新执行命令即可

    推荐镜像地址

    pip安装
    pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple/
    阿里云 http://mirrors.aliyun.com/pypi/simple/豆瓣(douban) pip install jupyterlab -i http://pypi.douban.com/simple/清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/中国科学技术大学http://pypi.mirrors.ustc.edu.cn/simple/
    pip install d2l==0.17.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/
    pytorch:http://121.199.45.168:8020/1/
    自然语言处理入门:http://121.199.45.168:8005/
    文本预处理:http://121.199.45.168:8003/1/#11
    经典序列模型:http://121.199.45.168:8004/1/
    RNN及其变体:http://121.199.45.168:8002/1/
    Transformer:http://121.199.45.168:8001/1/
    迁移学习:http://121.199.45.168:8007/1/

    物联沃分享整理
    物联沃-IOTWORD物联网 » Python安装、更新,第三方库时遇到:WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None···

    发表评论