淘先锋技术网

首页 1 2 3 4 5 6 7

版权声明:本文为博主原创文章,如需转载请贴上原博文链接:https://blog.csdn.net/u011628215/article/details/104770160


前言:由于之前写的一篇博客使用cmd安装Tensorflow失败解决办法(Windows64位系统)并没有完全解决问题,而是在使用cmd安装过程中出现“ReadTimeoutError: HTTPSConnectionPool”的问题,这里就写一些解决办法(会不断更新解决方法)。

 

问题:出现两个报错(下面是报错的代码):1.“socket.timeout: The read operation timed out”;2.“ReadTimeoutError: HTTPSConnectionPool”,总的来说,都是安装源的问题,也借鉴了很多网上的资料,下面一一尝试是否能成功。

Microsoft Windows [版本 10.0.19041.113]
(c) 2020 Microsoft Corporation. 保留所有权利。

C:\Users\jaysk>D:

D:\>pip install tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
Processing d:\tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
Collecting scipy==1.4.1; python_version >= "3" (from tensorflow==2.1.0)
  Downloading https://files.pythonhosted.org/packages/61/51/046cbc61c7607e5ecead6ff1a9453fba5e7e47a5ea8d608cc7036586a5ef/scipy-1.4.1-cp37-cp37m-win_amd64.whl (30.9MB)
     |█████████████████▌              | 16.9MB 4.5kB/s eta 0:51:24ERROR: Exception:
Traceback (most recent call last):
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 397, in _error_catcher
    yield
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 479, in read
    data = self._fp.read(amt)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "D:\Program Files (x86)\Anaconda3\lib\http\client.py", line 457, in read
    n = self.readinto(b)
  File "D:\Program Files (x86)\Anaconda3\lib\http\client.py", line 501, in readinto
    n = self.fp.readinto(b)
  File "D:\Program Files (x86)\Anaconda3\lib\socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "D:\Program Files (x86)\Anaconda3\lib\ssl.py", line 1071, in recv_into
    return self.read(nbytes, buffer)
  File "D:\Program Files (x86)\Anaconda3\lib\ssl.py", line 929, in read
    return 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 "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in main
    status = self.run(options, args)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 345, in run
    resolver.resolve(requirement_set)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\legacy_resolve.py", line 196, in resolve
    self._resolve_one(requirement_set, req)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\legacy_resolve.py", line 359, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\legacy_resolve.py", line 307, in _get_abstract_dist_for
    self.require_hashes
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 199, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 1064, in unpack_url
    progress_bar=progress_bar
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 924, in unpack_http_url
    progress_bar)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 1152, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 861, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\utils\hashes.py", line 75, in check_against_chunks
    for chunk in chunks:
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 829, in written_chunks
    for chunk in chunks:
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\utils\ui.py", line 156, in iter
    for x in it:
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_internal\download.py", line 818, in resp_read
    decode_content=False):
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 531, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 496, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "D:\Program Files (x86)\Anaconda3\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\Program Files (x86)\Anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 402, 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.

D:\>

解决方法:

方法一:使用Anaconda安装。这个方法不是我第一个想到的方法,但却是第一个成功安装Tensorflow的方法,所以放在第一个写,如图1所示,按照步骤进行,Python库中的Tensorflow如图2所示。

Anaconda安装Tensorflow
图1 Anaconda安装Tensorflow
Python库中的Tensorflow安装完毕
图2 Python库中的Tensorflow安装完毕

其他方法后续尝试再更新!!