关于python:通过pip安装tensorflow但是失败如下

Install tensorflow via pip but failed just as follows

Traceback (most recent call last):
File"/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File"/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File"/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File"/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File"/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url
hashes=hashes
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url
hashes)
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File"/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks
for chunk in chunks:
File"/usr/local/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter
for x in it:
File"/usr/local/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read
decode_content=False):
File"/usr/local/lib/python2.7/dist-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/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read
flush_decoder = True
File"/usr/lib/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File"/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 246, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.

[问题的图像描述]

网址:https://i.stack.imgur.com/iqxvu.png


我通过这样修改命令解决了这个问题:

1
pip --default-timeout=100 install THEPACKAGENAME

您也可以尝试使用车轮套装进行安装。车轮包取决于您拥有的操作系统类型、python版本以及您是否希望安装CPU/GPU支持。在安装TensorFlow之前,还要升级protobuf。

请在此处查找包裹列表:https://www.tensorflow.org/install/install_linux the_url_the_tensorflow_python_包

然后可以发出此命令:

1
2
$ sudo pip  install --upgrade <TF wheel package URL>   - For Python 2.7
$ sudo pip3 install --upgrade <TF wheel package URL>   - For Python 3.x

TensorFlow站点提供了一些常见安装问题的详细信息。你也可以看看这些,以防万一。

https://www.tensorflow.org/install/install_linux常见安装问题