安装tensorflow时出现KeyError



我试着安装tensorflow,但我得到了这个KeyError:

>py -3.7-64 -m pip install tensorflow
Collecting tensorflow
Downloading tensorflow-2.4.1-cp37-cp37m-win_amd64.whl (370.7 MB)
|██                              | 20.2 MB 3.3 MB/s eta 0:01:47ERROR: Exception:
Traceback (most recent call last):
File "C:...Python37libsite-packagespip_vendorresolvelibresolvers.py", line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: 'tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:...Python37libsite-packagespip_vendorurllib3response.py", line 438, in _error_catcher
yield
File "C:...Python37libsite-packagespip_vendorurllib3response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "C:...Python37libsite-packagespip_vendorcachecontrolfilewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "C:...Python37libhttpclient.py", line 461, in read
n = self.readinto(b)
File "C:...Python37libhttpclient.py", line 505, in readinto
n = self.fp.readinto(b)
File "C:...Python37libsocket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:...Python37libssl.py", line 1071, in recv_into
return self.read(nbytes, buffer)
File "C:...Python37libssl.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 "C:...Python37libsite-packagespip_internalclibase_command.py", line 189, in _main
status = self.run(options, args)
File "C:...Python37libsite-packagespip_internalclireq_command.py", line 178, in wrapper
return func(self, options, args)
File "C:...Python37libsite-packagespip_internalcommandsinstall.py", line 317, in run
reqs, check_supported_wheels=not options.target_dir
File "C:...Python37libsite-packagespip_internalresolutionresolvelibresolver.py", line 122, in resolve
requirements, max_rounds=try_to_avoid_resolution_too_deep,
File "C:...Python37libsite-packagespip_vendorresolvelibresolvers.py", line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:...Python37libsite-packagespip_vendorresolvelibresolvers.py", line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "C:...Python37libsite-packagespip_vendorresolvelibresolvers.py", line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File "C:...Python37libsite-packagespip_vendorresolvelibresolvers.py", line 82, in from_requirement
if not cands:
File "C:...Python37libsite-packagespip_vendorresolvelibstructs.py", line 124, in __bool__
return bool(self._sequence)
File "C:...Python37libsite-packagespip_internalresolutionresolvelibfound_candidates.py", line 143, in __bool__
return any(self)
File "C:...Python37libsite-packagespip_internalresolutionresolvelibfound_candidates.py", line 38, in _iter_built
candidate = func()
File "C:...Python37libsite-packagespip_internalresolutionresolvelibfactory.py", line 169, in _make_candidate_from_link
name=name, version=version,
File "C:...Python37libsite-packagespip_internalresolutionresolvelibcandidates.py", line 306, in __init__
version=version,
File "C:...Python37libsite-packagespip_internalresolutionresolvelibcandidates.py", line 144, in __init__
self.dist = self._prepare()
File "C:...Python37libsite-packagespip_internalresolutionresolvelibcandidates.py", line 226, in _prepare
dist = self._prepare_distribution()
File "C:...Python37libsite-packagespip_internalresolutionresolvelibcandidates.py", line 312, in _prepare_distribution
self._ireq, parallel_builds=True,
File "C:...Python37libsite-packagespip_internaloperationsprepare.py", line 457, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "C:...Python37libsite-packagespip_internaloperationsprepare.py", line 482, in _prepare_linked_requirement
self.download_dir, hashes,
File "C:...Python37libsite-packagespip_internaloperationsprepare.py", line 234, in unpack_url
hashes=hashes,
File "C:...Python37libsite-packagespip_internaloperationsprepare.py", line 108, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "C:...Python37libsite-packagespip_internalnetworkdownload.py", line 163, in __call__
for chunk in chunks:
File "C:...Python37libsite-packagespip_internalcliprogress_bars.py", line 159, in iter
for x in it:
File "C:...Python37libsite-packagespip_internalnetworkutils.py", line 88, in response_chunks
decode_content=False,
File "C:...Python37libsite-packagespip_vendorurllib3response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:...Python37libsite-packagespip_vendorurllib3response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "C:...Python37libcontextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "C:...Python37libsite-packagespip_vendorurllib3response.py", line 443, 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.

然后我尝试使用虚拟环境(venv)安装它,这次进度条走得更远了一点,但它仍然抛出了几乎相同的错误。

有什么办法解决这个问题吗?

谢谢。

只需在安装时使用——default-timeout=100参数。如

py -3.7-64 -m pip install --default-timeout=100 tensorflow

我希望这对你有帮助。

我已经尝试了很多方法,但没有用。最后我不得不重新安装我的python,它工作了。

相关内容

  • 没有找到相关文章

最新更新