您当前的位置:首页 > 计算机 > 编程开发 > Python

Python 安装包超时报错问题解决方案

时间:05-17来源:作者:点击数:

python安装库时,超时报错如下

pip install jieba
Collecting jieba
  Downloading https://files.pythonhosted.org/packages/71/46/c6f9179f73b818d5827202ad1c4a94e371a29473b7f043b736b4dab6b8cd/jieba-0.39.zip (7.3MB)
    73% |███████████████████████▋        | 5.4MB 51kB/s eta 0:00:38Exception:
Traceback (most recent call last):
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 226, in _error_catcher
    yield
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 301, in read
    data = self._fp.read(amt)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 49, in read
    data = self.__fp.read(amt)
  File "/home/hduser/anaconda3/lib/python3.5/http/client.py", line 433, in read
    n = self.readinto(b)
  File "/home/hduser/anaconda3/lib/python3.5/http/client.py", line 473, in readinto
    n = self.fp.readinto(b)
  File "/home/hduser/anaconda3/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
  File "/home/hduser/anaconda3/lib/python3.5/ssl.py", line 924, in recv_into
    return self.read(nbytes, buffer)
  File "/home/hduser/anaconda3/lib/python3.5/ssl.py", line 786, in read
    return self._sslobj.read(len, buffer)
  File "/home/hduser/anaconda3/lib/python3.5/ssl.py", line 570, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/commands/install.py", line 310, in run
    wb.build(autobuilding=True)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/req/req_set.py", line 577, in _prepare_file
    session=self.session, hashes=hashes)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 810, in unpack_url
    hashes=hashes
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 649, in unpack_http_url
    hashes)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 871, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 595, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks
    for chunk in chunks:
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 563, in written_chunks
    for chunk in chunks:
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/utils/ui.py", line 139, in iter
    for x in it:
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/download.py", line 552, in resp_read
    decode_content=False):
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 344, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 311, in read
    flush_decoder = True
  File "/home/hduser/anaconda3/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/hduser/anaconda3/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 231, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
You are using pip version 8.1.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解决方案:

方案一:

pip --default-timeout=100  install -U  库名

方案二:

easy-install  库名

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门