[英]How to install tensorflow?
I am having some difficulties in installing TensorFlow on my computer.我在计算机上安装 TensorFlow 时遇到了一些困难。
My OS: Windows 8我的操作系统:Windows 8
My Python version: 3.7 (64-bit)我的 Python 版本:3.7(64 位)
I used pip install Tensorflow我用 pip install Tensorflow
https://www.tensorflow.org/install/pip https://www.tensorflow.org/install/pip
Should I copy its commands to cmd?我应该将其命令复制到 cmd 吗? Or I should change some details of them accordingly?
或者我应该相应地更改它们的一些细节?
For example:例如:
I tried running code:我尝试运行代码:
pip3 install -U pip virtualenv
Here is what I get:这是我得到的:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Users\A>virtualenv --system-site-packages -p python3 ./venv
The path python3 (from --python=python3) does not exist
What does it mean by "the path does not exist"? “路径不存在”是什么意思? I tried changing "python3 ."
我尝试更改“python3”。 to "python3.7 .", but it doesn't work out.
到“python3.7 .”,但它不起作用。
Even tho the first command didn't work out, it seems the pip, python, and virtualenv are installed on my PC.即使第一个命令没有成功,我的 PC 上似乎也安装了 pip、python 和 virtualenv。
Here is the issue I have when I try to download Tensorflow:这是我尝试下载 Tensorflow 时遇到的问题:
I tried running code:我尝试运行代码:
pip install --upgrade tensorflow
This is the error:这是错误:
C:\Users\A>.\venv\Scripts\activate
The system cannot find the path specified.
C:\Users\A>pip install --upgrade pip
Requirement already up-to-date: pip in c:\users\a\appdata\local\programs\python\
python37\lib\site-packages (20.0.2)
C:\Users\A>
C:\Users\A>pip list # show packages installed within the virtual environment
Package Version
---------- -------
pip 20.0.2
setuptools 45.1.0
virtualenv 16.7.9
wheel 0.34.2
C:\Users\A>pip install --upgrade tensorflow
Collecting tensorflow
Downloading tensorflow-2.1.0-cp37-cp37m-win_amd64.whl (355.8 MB)
| | 788 kB 3.2 kB/s eta 1 day, 6:26:40ERROR:
Exception:
Traceback (most recent call last):
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\urllib3\response.py", line 425, in _error_catcher
yield
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\urllib3\response.py", line 507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "c:\users\a\appdata\local\programs\python\python37\lib\http\client.py", l
ine 457, in read
n = self.readinto(b)
File "c:\users\a\appdata\local\programs\python\python37\lib\http\client.py", l
ine 501, in readinto
n = self.fp.readinto(b)
File "c:\users\a\appdata\local\programs\python\python37\lib\socket.py", line 5
89, in readinto
return self._sock.recv_into(b)
File "c:\users\a\appdata\local\programs\python\python37\lib\ssl.py", line 1071
, in recv_into
return self.read(nbytes, buffer)
File "c:\users\a\appdata\local\programs\python\python37\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 "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\cli\base_command.py", line 186, in _main
status = self.run(options, args)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\commands\install.py", line 331, in run
resolver.resolve(requirement_set)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\operations\prepare.py", line 482, in prepare_linked_requirement
hashes=hashes,
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\operations\prepare.py", line 287, in unpack_url
hashes=hashes,
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\operations\prepare.py", line 159, in unpack_http_url
link, downloader, temp_dir.path, hashes
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\operations\prepare.py", line 303, in _download_http_url
for chunk in download.chunks:
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\utils\ui.py", line 160, in iter
for x in it:
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_internal\network\utils.py", line 39, in response_chunks
decode_content=False,
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\urllib3\response.py", line 564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\urllib3\response.py", line 529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "c:\users\a\appdata\local\programs\python\python37\lib\contextlib.py", li
ne 130, in __exit__
self.gen.throw(type, value, traceback)
File "c:\users\a\appdata\local\programs\python\python37\lib\site-packages\pip\
_vendor\urllib3\response.py", line 430, 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.
C:\Users\A>https://github.com/tensorflow/tensorflow/issues/5949
How can I install Tensorflow?如何安装 Tensorflow? Thank you!
谢谢!
Update 1:更新 1:
When I change 'python 3' to 'python', and 'pip3' to 'pip', the first few command lines work out.当我将“python 3”更改为“python”,将“pip3”更改为“pip”时,前几个命令行会起作用。
However, I still can't download Tensorflow.但是,我仍然无法下载 Tensorflow。
A bit more has been downloaded this time:这次下载了更多:
(venv) C:\Users\A> pip install --upgrade tensorflow
Collecting tensorflow
Downloading tensorflow-2.1.0-cp37-cp37m-win_amd64.whl (355.8 MB)
|█ | 8.4 MB 10.0 kB/s eta 9:40:28ERROR: Exce
ption:
Traceback (most recent call last):
File "c:\users\a\venv\lib\site-packages\pip\_vendor\urllib3\response.py", line
425, in _error_catcher
yield
File "c:\users\a\venv\lib\site-packages\pip\_vendor\urllib3\response.py", line
507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "c:\users\a\venv\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.p
y", line 62, in read
data = self.__fp.read(amt)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\Lib\http\client.py", l
ine 457, in read
n = self.readinto(b)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\Lib\http\client.py", l
ine 501, in readinto
n = self.fp.readinto(b)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\Lib\socket.py", line 5
89, in readinto
return self._sock.recv_into(b)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\Lib\ssl.py", line 1071
, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\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 "c:\users\a\venv\lib\site-packages\pip\_internal\cli\base_command.py", li
ne 186, in _main
status = self.run(options, args)
File "c:\users\a\venv\lib\site-packages\pip\_internal\commands\install.py", li
ne 331, in run
resolver.resolve(requirement_set)
File "c:\users\a\venv\lib\site-packages\pip\_internal\legacy_resolve.py", line
177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "c:\users\a\venv\lib\site-packages\pip\_internal\legacy_resolve.py", line
333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "c:\users\a\venv\lib\site-packages\pip\_internal\legacy_resolve.py", line
282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "c:\users\a\venv\lib\site-packages\pip\_internal\operations\prepare.py",
line 482, in prepare_linked_requirement
hashes=hashes,
File "c:\users\a\venv\lib\site-packages\pip\_internal\operations\prepare.py",
line 287, in unpack_url
hashes=hashes,
File "c:\users\a\venv\lib\site-packages\pip\_internal\operations\prepare.py",
line 159, in unpack_http_url
link, downloader, temp_dir.path, hashes
File "c:\users\a\venv\lib\site-packages\pip\_internal\operations\prepare.py",
line 303, in _download_http_url
for chunk in download.chunks:
File "c:\users\a\venv\lib\site-packages\pip\_internal\utils\ui.py", line 160,
in iter
for x in it:
File "c:\users\a\venv\lib\site-packages\pip\_internal\network\utils.py", line
39, in response_chunks
decode_content=False,
File "c:\users\a\venv\lib\site-packages\pip\_vendor\urllib3\response.py", line
564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "c:\users\a\venv\lib\site-packages\pip\_vendor\urllib3\response.py", line
529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "C:\Users\A\AppData\Local\Programs\Python\Python37\Lib\contextlib.py", li
ne 130, in __exit__
self.gen.throw(type, value, traceback)
File "c:\users\a\venv\lib\site-packages\pip\_vendor\urllib3\response.py", line
430, 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) C:\Users\A>
Update 2:更新 2:
I used the following command line:我使用了以下命令行:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
Much more was downloaded.下载了更多。
Here is the new error:这是新的错误:
ERROR: Could not find a version that satisfies the requirement tensorboard<2.2.0
,>=2.1.0 (from tensorflow) (from versions: 1.6.0rc0, 1.6.0, 1.7.0, 1.8.0, 1.9.0,
1.10.0, 1.11.0, 1.12.0, 1.12.1, 1.12.2, 1.13.0, 1.13.1, 1.14.0, 1.15.0, 2.0.0,
2.0.1, 2.0.2)
ERROR: No matching distribution found for tensorboard<2.2.0,>=2.1.0 (from tensor
flow)
C:\Users\A>
Do I need a different version of Tensorflow?我需要不同版本的 Tensorflow 吗?
Use below commands to install TensorFlow inside virtual environment.使用以下命令在虚拟环境中安装 TensorFlow。
1) upgrade pip3: python3 -m pip install --upgrade pip 2) Install virtual env pip3 install virtualenv 3) You can then create a virtualenv using the full path of python3 like this: virtualenv -p /home/example_username/opt/python-3.6.2/bin/python3 venv 4) Activate virtual env source venv/bin/activate 5) install tensorflow pip3 install tensorflow 1) 升级 pip3: python3 -m pip install --upgrade pip 2) 安装虚拟环境pip3 install virtualenv 3) 然后你可以使用 python3 的完整路径创建一个 virtualenv,如下所示: virtualenv -p /home/example_username/opt/python -3.6.2/bin/python3 venv 4) 激活虚拟环境源 venv/bin/activate 5) 安装 tensorflow pip3 install tensorflow
please note this error message.请注意此错误消息。
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files
.pythonhosted.org', port=443): Read timed out.
It seems that you can't connect to files.pythonhosted.org
.您似乎无法连接到
files.pythonhosted.org
。 You can visit this url: https://pypi.org/project/tensorflow/#files to down tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
first.您可以访问此网址: https :
tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
以首先关闭tensorflow-2.1.0-cp37-cp37m-win_amd64.whl
。 And then use pip install <name>.whl
to install it.然后使用
pip install <name>.whl
进行安装。
More: If you are in China, you can use bellow command to install tensorflow
from tsinghua University.更多:如果你在中国,你可以使用bellow命令安装清华大学的
tensorflow
。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.