pip install 安装库时出现超时Read timed out

本文详细介绍了在使用pip安装numpy过程中遇到的超时错误及其解决方案,包括调整超时时间、更换下载源如豆瓣源,以及下载离线包的方法。

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

C:\Users\kk>pip install numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting numpy
  Downloading https://files.pythonhosted.org/packages/7f/65/a5a0ca3695bb3358faef4bd2131c8174aef78c4b2182d8cae404312bcc26/numpy-1.16.2-cp27-cp27m-win_amd64.whl (11.8MB)
    49% |████████████████                | 5.9MB 39kB/s eta 0:02:32Exception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\cli\base_command.py", line 179, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\commands\install.py", line 315, in run
    resolver.resolve(requirement_set)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\resolve.py", line 131, in resolve
    self._resolve_one(requirement_set, req)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\resolve.py", line 294, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\resolve.py", line 242, in _get_abstract_dist_for
    self.require_hashes
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\operations\prepare.py", line 334, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 878, in unpack_url
    progress_bar=progress_bar
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 702, in unpack_http_url
    progress_bar)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 946, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 639, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\utils\hashes.py", line 62, in check_against_chunks
    for chunk in chunks:
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 607, in written_chunks
    for chunk in chunks:
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\utils\ui.py", line 159, in iter
    for x in it:
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_internal\download.py", line 596, in resp_read
    decode_content=False):
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_vendor\urllib3\response.py", line 494, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_vendor\urllib3\response.py", line 459, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Python27\lib\contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python27\lib\site-packages\pip-19.0.3-py2.7.egg\pip\_vendor\urllib3\response.py", line 374, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

出现以上错误可能是因为网络环境不佳导致的

解决方案一:

在安装时设置默认超时时间    

例如:pip --default-timeout=100 install 模块名

如果还是报错请看方案二

解决方案二:

更换下载源,网上推荐使用豆瓣下载源

例如:pip install --index-url https://pypi.douban.com/simple 模块名

一般这到一步都会解决,如果源中没有对应模块,请使用方案三

解决方案三:

下载离线包

可以去Unofficial Windows Binaries for Python Extension Packages下载,然后安装。 

点击后下载到pip.exe所在的Scripts/文件目录下,这个时候再运行

pip install XXX.whl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值