win10 tensorflow安装教程 超详细 小白手把手教程
一.安装anaconda3(最好安装4.2.0版本)
网址:点击打开链接
选择anaconda3 4.2.0下载
我之前安装过anaconda2,所以网上查找了很多方法,在下载完成anaconda3后,一直下一步,当出现安装路径的时候,要注意:
把anaconda3安装在anaconda2/envs下,先选择这个路径,如下图:
在此一定要注意,不要新建文件夹,否则会出现如下问题:
此时应该删除anaconda3这个空文件夹,在D:\Anaconda2\envs\后面手打Anaconda3\,这样就可以顺利安装了。
然后将anaconda3、Anaconda3\Scripts、Anaconda3\Library\bin的路径添加到用户变量PATH中。
二.VS2015企业版
安装过程很慢,耐心等待。
三.pip安装
这一步很关键,往往网上说的都是直接更新pip,但是往往出现诸如以下的错误:
C:\Users\Administrator>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
d:\anaconda2\python.exe -m pip install --upgrade pip
我以为是我之前安装过anaconda2,所以默认的是anaconda2,故将目录跳转到anaconda3下,结果如下:
D:\Anaconda2\envs>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
d:\anaconda2\python.exe -m pip install --upgrade pip
还是出现了错误。后来我想是不是需要进入anaconda3根目录文件夹下才可以进行下载,故cd anaconda3:
D:\Anaconda2\envs\Anaconda3>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
d:\anaconda2\python.exe -m pip install --upgrade pip
还是报错!然后我尝试使用调用python的exe文件进行安装,结果:
D:\Anaconda2\envs\Anaconda3>python.exe pip install --upgrade pip
python.exe: can't open file 'pip': [Errno 2] No such file or directory
还是报错!因为看介绍文章说,这一步可以跳过,所以我想直接下一步,试试可不可以,结果:
D:\Anaconda2\envs\Anaconda3>pip install tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
我重新尝试在envs目录下更新pip:
D:\Anaconda2\envs>pip install --upgrade
ERROR: You must give at least one requirement to install (see "pip help install")
这个时候出现了很关键的一条语句,说我至少应该安装一个需求,查看help后,没看到什么有用信息。这个时候我想到anaconda2切换到3再进行操作,于是,我用:
D:\Anaconda2\envs\Anaconda3>activate anaconda3
在3下进行:
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Exception:
Traceback (most recent call last):
File "D:\Anaconda2\envs\anaconda3\lib\shutil.py", line 538, in move
os.rename(src, real_dst)
OSError: [WinError 17] 系统无法将文件移到不同的磁盘驱动器。: 'd:\\anaconda2\\envs\\anaconda3\\scripts\\pip.exe' -> 'C:\\Users\\ADMINI~2\\AppData\\Local\\Temp\\pip-05t8j53u-uninstall\\anaconda2\\envs\\anaconda3\\scripts\\pip.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\commands\install.py", line 317, in run
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\req\req_set.py", line 736, in install
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\req\req_install.py", line 742, in uninstall
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip\utils\__init__.py", line 267, in renames
File "D:\Anaconda2\envs\anaconda3\lib\shutil.py", line 553, in move
os.unlink(src)
PermissionError: [WinError 5] 拒绝访问。: 'd:\\anaconda2\\envs\\anaconda3\\scripts\\pip.exe'
还是有错,接着我直接安装tensorflow:
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install tensorflow
Cannot open D:\Anaconda2\envs\anaconda3\Scripts\pip-script.py
还是报错,找不到pip-script.py这个文件,搜索后发现需要先安装pip,汗!于是在此目录下,easy_install pip进行了下载:
(anaconda3) D:\Anaconda2\envs\Anaconda3>easy_install pip
然后pip install dicom:
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install dicom
然后才进入我们一开始的那一步
pip install --upgrade pip
终于可以了!
四.安装tensorflow
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
D:\Anaconda2\envs\anaconda3\python.exe -m pip install --upgrade pip
需要用python 进行更新
(anaconda3) D:\Anaconda2\envs\Anaconda3>python.exe -m pip install --upgrade pip
然后下载安装tensorflow
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install tensorflow
你会发现出现很长的红字报错
Traceback (most recent call last):
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\urllib3\response.py", line 302, in _error_catcher
yield
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\urllib3\response.py", line 384, in read
data = self._fp.read(amt)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\cachecontrol\filewrapper.py", line 60, in read
data = self.__fp.read(amt)
File "D:\Anaconda2\envs\anaconda3\lib\http\client.py", line 448, in read
n = self.readinto(b)
File "D:\Anaconda2\envs\anaconda3\lib\http\client.py", line 488, in readinto
n = self.fp.readinto(b)
File "D:\Anaconda2\envs\anaconda3\lib\socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "D:\Anaconda2\envs\anaconda3\lib\ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File "D:\Anaconda2\envs\anaconda3\lib\ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File "D:\Anaconda2\envs\anaconda3\lib\ssl.py", line 575, in read
v = 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:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\basecommand.py", line 228, in main
status = self.run(options, args)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\commands\install.py", line 291, in run
resolver.resolve(requirement_set)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\resolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\resolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\resolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\operations\prepare.py", line 310, in prepare_linked_requirement
progress_bar=self.progress_bar
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 837, in unpack_url
progress_bar=progress_bar
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 674, in unpack_http_url
progress_bar)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 898, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 618, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\utils\hashes.py", line 48, in check_against_chunks
for chunk in chunks:
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 586, in written_chunks
for chunk in chunks:
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\utils\ui.py", line 159, in iter
for x in it:
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_internal\download.py", line 575, in resp_read
decode_content=False):
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\urllib3\response.py", line 436, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\urllib3\response.py", line 401, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "D:\Anaconda2\envs\anaconda3\lib\contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "D:\Anaconda2\envs\anaconda3\lib\site-packages\pip-10.0.1-py3.5.egg\pip\_vendor\urllib3\response.py", line 307, 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.
我们通过如下命令查看:
(anaconda3) D:\Anaconda2\envs\Anaconda3>conda config --show
会发现add_anaconda_token: True
add_pip_as_python_dependency: True
allow_softlinks: True
always_copy: False
always_yes: False
auto_update_conda: True
binstar_upload: None
changeps1: True
channel_alias: https://conda.anaconda.org/
channel_priority: True
channels:
- defaults
client_cert:
client_cert_key:
create_default_packages: []
debug: False
default_channels:
- https://repo.continuum.io/pkgs/free
- https://repo.continuum.io/pkgs/pro
- https://repo.continuum.io/pkgs/msys2
disallow: []
json: False
offline: False
proxy_servers: {}
quiet: False
shortcuts: True
show_channel_urls: None
ssl_verify: True
track_features: []
update_dependencies: True
use_pip: True
verbosity: 0
网址是https://conda.anaconda.org/,因为是国外网站,所以下载网速很慢,经常出现下载超时的提醒,尝试多次会发现一直都不能成功,我们可以采用修改pip源的方法,把地址改为阿里的:
(anaconda3) D:\Anaconda2\envs\Anaconda3>pip install tensorflow -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
很快下载完成。成功!
接下来对安装好的tensorflow进行测试:
(anaconda3) D:\Anaconda2\envs\Anaconda3>python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> a = tf.constant("hello world")
>>> sess = tf.Session()
2018-05-30 19:34:34.977362: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
>>> print(sess.run(a))
b'hello world'
>>> exit()
成功!推荐阅读
-
如何运行openSUSE?Win10中安装SUSE Linux子系统的详细图文教程
-
Win10系统安装教程: 最靠谱Win10重置与重装系统详细图文教程
-
AutoCAD Mechanical 2013 WIN10系统环境下安装教程详细图解
-
CentOS6.4 下安装SVN的详细教程(超详细)
-
手把手教你如何安装Pycharm(详细图文教程)
-
如何使用U盘安装纯净原版Win10系统?U盘安装纯净原版Win10系统详细图文教程
-
详细完整的Tensorflow-gpu环境安装教程
-
苹果Mac上安装Win10技术预览版的详细教程
-
VMware Workstation安装并安装WIN10操作系统连接外网步骤指导(超详细教程)
-
强烈推荐,超详细,实操零失误:node.js安装 + npm安装教程 + Vue开发环境搭建 【非原创,但是用生命推荐的转载】