解决pip install安装软件出现的Retry(total=4, connect=None, read=None, redirect=None, status=None)问题

本机系统环境介绍

Ubuntu系统环境介绍介绍
Ubuntu版本:18.04.1
系统配置: 64位
Linux内核:5.3.0-42-generic
说明:本人实在安装docker-compose时出现的问题

错误演示

acestang@acestang:~$ sudo pip install docker-compose
The directory '/home/acestang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/acestang/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting docker-compose
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. (read timeout=15)",)': /simple/docker-compose/
  Downloading https://files.pythonhosted.org/packages/ec/35/1dfbb8e6b2ce5d290622a49cae0a7f3cf09cdc4341380a600aee00530881/docker_compose-1.25.5-py2.py3-none-any.whl (139kB)
    100% |████████████████████████████████| 143kB 9.2kB/s 
Requirement already satisfied: six<2,>=1.3.0 in /usr/lib/python3/dist-packages (from docker-compose)
Collecting docopt<1,>=0.6.1 (from docker-compose)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, '连接被对方重设'))': /simple/docopt/
  Could not find a version that satisfies the requirement docopt<1,>=0.6.1 (from docker-compose) (from versions: )
No matching distribution found for docopt<1,>=0.6.1 (from docker-compose)

解决思路

问题分析

这个问题是在安装软件过程中,链接国外的镜像源导致下载失败

常用的国内镜像源

名称源地址host地址
清华https://pypi.tuna.tsinghua.edu.cn/simple/pypi.tuna.tsinghua.edu.cn
阿里云http://mirrors.aliyun.com/pypi/simple/mirrors.aliyun.com
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/pypi.mirrors.ustc.edu.cn
华中理工大学http://pypi.hustunique.com/pypi.hustunique.com
山东理工大学http://pypi.sdutlinux.org/pypi.sdutlinux.org
豆瓣http://pypi.douban.com/simple/pypi.douban.com

第一种解决办法,安装软件时制定源

# -i 后面指的是镜像地址
# --trusted-host 作用是添加信任的host,地址为镜像的IP或者域名
acestang@acestang:~$ pip install docker-compose -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
Collecting docker-compose
  Downloading http://mirrors.aliyun.com/pypi/packages/ec/35/1dfbb8e6b2ce5d290622a49cae0a7f3cf09cdc4341380a600aee00530881/docker_compose-1.25.5-py2.py3-none-any.whl (139kB)
    100% |████████████████████████████████| 143kB 168kB/s 
Collecting PyYAML<6,>=3.10 (from docker-compose)
  Downloading http://mirrors.aliyun.com/pypi/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)
    100% |████████████████████████████████| 276kB 349kB/s 
Collecting docopt<1,>=0.6.1 (from docker-compose)
  Downloading http://mirrors.aliyun.com/pypi/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
Collecting jsonschema<4,>=2.5.1 (from docker-compose)
  Downloading http://mirrors.aliyun.com/pypi/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56kB)
  ....
 Installing collected packages: docker-compose
Successfully installed docker-compose-1.25.5
# 安装成功,问题解决

第二种解决办法,修改配置文件制定源

把pip安装软件的时候配置成默认的源
修改地址:
~/.pip/pip.conf 或者/etc.pip.conf
如果当前目录下没有该文件,可以直接创建

acestang@acestang:~$ sudo vi /etc/pip.conf
# 添加文件
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/ # 阿里源,稳定
extra-index-url = http://pypi.douban.com/simple/ # 备用源,选择豆瓣的
trusted-host =             
    mirrors.aliyun.com      #添加阿里源为可信主机,要不然可能报错
    pypi.douban.com         #豆瓣主机
# 保存退出
# 继续执行命令安装
acestang@acestang:~$ sudo pip install -U docker-compose
The directory '/home/acestang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/acestang/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting docker-compose
  Url '#/docker-compose/' is ignored. It is either a non-existing path or lacks a specific scheme.
  .......
  Requirement already up-to-date: cffi>=1.4.1 in ./.local/lib/python3.6/site-packages (from pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]<5,>=3.7.0->docker-compose)
Url '#/pycparser/' is ignored. It is either a non-existing path or lacks a specific scheme.
Url '备用源,选择豆瓣的/pycparser/' is ignored. It is either a non-existing path or lacks a specific scheme.
Installing collected packages: docker-compose
Successfully installed docker-compose-1.25.5
# 安装成功
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值