pip 安裝 docker-compose 超時


1:安裝命令

pip install docker-compose

 異常信息

 

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 docker-compose

 

這個應該是沒有FQ導致下載超時。所以需要修改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/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM