小知识:PIP安装docker-compose超时问题解决方案

1:安装命令

pip install dockercompose

异常信息

socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/local/lib/python3.6/site-packages/pip/_internal/cli/base_command.py”, line 188, in _main

status = self.run(options, args)

File “/usr/local/lib/python3.6/site-packages/pip/_internal/cli/req_command.py”, line 185, in wrapper

return func(self, options, args)

File “/usr/local/lib/python3.6/site-packages/pip/_internal/commands/install.py”, line 333, in run

reqs, check_supported_wheels=not options.target_dir

File “/usr/local/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 179, in resolve

discovered_reqs.extend(self._resolve_one(requirement_set, req))

File “/usr/local/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 362, in _resolve_one

abstract_dist = self._get_abstract_dist_for(req_to_install)

File “/usr/local/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py”, line 314, in _get_abstract_dist_for

abstract_dist = self.preparer.prepare_linked_requirement(req)

File “/usr/local/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 469, in prepare_linked_requirement

hashes=hashes,

File “/usr/local/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 259, in unpack_url

hashes=hashes,

File “/usr/local/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 130, in get_http_url

link, downloader, temp_dir.path, hashes

File “/usr/local/lib/python3.6/site-packages/pip/_internal/operations/prepare.py”, line 281, in _download_http_url

for chunk in download.chunks:

File “/usr/local/lib/python3.6/site-packages/pip/_internal/cli/progress_bars.py”, line 166, in iter

for x in it:

File “/usr/local/lib/python3.6/site-packages/pip/_internal/network/utils.py”, line 39, in response_chunks

decode_content=False,

File “/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py”, line 564, in stream

data = self.read(amt=amt, decode_content=decode_content)

File “/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py”, line 529, in read

raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

File “/usr/lib64/python3.6/contextlib.py”, line 99, in __exit__

self.gen.throw(type, value, traceback)

File “/usr/local/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py”, line 430, in _error_catcher

raise ReadTimeoutError(self._pool, None, “Read timed out.”)

pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=files.pythonhosted.org, port=443): Read timed out.

网上有网友说加上超时时间,但并没有解决我这个问题。

pip –default-timeout=100 install dockercompose

这个应该是没有翻墙导致下载超时。所以需要修改pip 的源

按照网上例子,临时修改了pip的源,再次执行安装命令,也没有解决我的问题

[root@localhost bin]# pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/

后来又看到一篇博客,这种方式解决了我的问题,修改源借鉴的是https://blog.csdn.net/h106140873/article/details/103858931 博客。

1:在根目录下创建pip文件夹(我是使用的root用户)

mkdir ~/.pip

2:在 .pip目录中创建 pip.conf文件

touch pip.conf

3:编辑 pip.conf 文件,添加如下两行内容

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

再次执行 pip –default-timeout=100 install docker-compose 命令,安装成功。并且下载速度很快

注: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/

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://www.cnblogs.com/zhangXingSheng/p/13371690.html

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:Docker CentOS7的系统上安装部署以及基础教程

2023-4-24 12:21:25

建站知识

小知识:Docker使用过程中的一些注意事项

2023-4-24 12:35:58

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索