Mac python3 下安装matplotlib出现ReadTimeoutError(self._pool, None, 'Read timed out.')的报错

本文介绍了解决使用pip3安装matplotlib时遇到的网络超时问题,提供了两种解决方案:一是更换下载源,二是延长pip3的默认超时时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Mac-Mini:~ BBT$ pip3 install matplotlib

Collecting matplotlib

  Downloading matplotlib-2.1.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (13.2MB)

    0% |                                | 20kB 9.5kB/s eta 0:23:07Exception:

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 232, in _error_catcher

    yield

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read

    data = self._fp.read(amt)

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read

    data = self.__fp.read(amt)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 449, in read

    n = self.readinto(b)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 493, in readinto

    n = self.fp.readinto(b)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto

    return self._sock.recv_into(b)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1009, in recv_into

    return self.read(nbytes, buffer)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 871, in read

    return self._sslobj.read(len, buffer)

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 631, 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 "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main

    status = self.run(options, args)

  File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 335, in run

    wb.build(autobuilding=True)

  File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 749, in build

    self.requirement_set.prepare_files(self.finder)

  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files

    ignore_dependencies=self.ignore_dependencies))

  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file

    session=self.session, hashes=hashes)

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 821, in unpack_url

    hashes=hashes

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 659, in unpack_http_url

    hashes)

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 882, in _download_http_url

    _download_url(resp, link, content_file, hashes)

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 603, in _download_url

    hashes.check_against_chunks(downloaded_chunks)

  File "/usr/local/lib/python3.6/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks

    for chunk in chunks:

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 571, in written_chunks

    for chunk in chunks:

  File "/usr/local/lib/python3.6/site-packages/pip/utils/ui.py", line 139, in iter

    for x in it:

  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 560, in resp_read

    decode_content=False):

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream

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

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read

    flush_decoder = True

  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 99, in __exit__

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

  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 237, in _error_catcher

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

pip._vendor.requests.packages.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

Mac-Mini:~ BBT$ pip3 --default -timeout=100 install -U pip3

 

Usage:   

  pip <command> [options]

 

ambiguous option: --default (--default-timeout, --default-vcs?)

Mac-Mini:~ BBT$ pip3 --default-timeout=100 install -U pip3

Collecting pip3

  Could not find a version that satisfies the requirement pip3 (from versions: )

No matching distribution found for pip3

Mac-Mini:~ BBT$ pip3 install -U --timeout 1000 matplotlib

 

    出现上述问题,主要是请求网络超时,这由于是国内的源的问题。所以解决这问题有两个方案:

    1.换源,这个我没有尝试过,但是网上的教程也是挺多的;

    2.设置pip3获取第三方库的请求超时时间。pip3 install -U --timeout 1000 matplotlib

 

转载于:https://www.cnblogs.com/IT-DavidYang/p/7807744.html

pip install "numpy<1.17" scipy matplotlib Collecting numpy<1.17 Downloading https://files.pythonhosted.org/packages/3a/5f/47e578b3ae79e2624e205445ab77a1848acdaa2929a00eeef6b16eaaeb20/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB) 100% |████████████████████████████████| 17.0MB 56kB/s Collecting scipy Downloading https://files.pythonhosted.org/packages/24/40/11b12af7f322c1e20446c037c47344d89bab4922b8859419d82cf56d796d/scipy-1.2.3-cp27-cp27mu-manylinux1_x86_64.whl (24.8MB) 100% |████████████████████████████████| 24.8MB 56kB/s Collecting matplotlib Downloading https://files.pythonhosted.org/packages/9d/40/5ba7d4a3f80d39d409f21899972596bf62c8606f1406a825029649eaa439/matplotlib-2.2.5-cp27-cp27mu-manylinux1_x86_64.whl (12.8MB) 22% |███████▏ | 2.9MB 6.9kB/s eta 0:24:08Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url hashes=hashes File "/usr/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url hashes) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 902, in _download_http_url _download_url(resp, link, content_file, hashes) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/usr/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/usr/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/usr/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter for x in it: File "/usr/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read decode_content=False): File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 436, in stream data = self.read(amt=amt, decode_content=decode_content) File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 401, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 316, in _error_catcher raise ReadTimeoutError(self._pool, None, &#39;Read timed out.&#39;) ReadTimeoutError: HTTPSConnectionPool(host=&#39;files.pythonhosted.org&#39;, port=443): Read timed out. zsy@zsy-virtual-machine:~$
最新发布
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值