版权声明:勤学 修德 明辨 笃实 - CSDN周雄伟					https://blog.csdn.net/ebzxw/article/details/80701613				</div>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f1a9c33fcd.css">
<div class="htmledit_views" id="content_views">
<p>已有环境:python3.7.1<br></p><p>anaconda隔离管理多个环境,互不影响。这里,在anaconda中安装最新的python3.6.5 版本。</p><p>linux环境下使用anaconda安装tensorflow步骤见:<a href="https://blog.csdn.net/ebzxw/article/details/80693152" rel="nofollow" target="_blank">https://blog.csdn.net/ebzxw/article/details/80693152</a></p><p><strong>一. 安装anaconda</strong></p><p>1. 下载地址:&nbsp;<a href="https://www.anaconda.com/download/#windows" rel="nofollow" target="_blank">https://www.anaconda.com/download/#windows</a></p><p><img src="https://img-blog.csdn.net/20180615101323644?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p>2.&nbsp; 执行下载文件&nbsp;&nbsp;Anaconda3-5.2.0-<a href="https://www.baidu.com/s?wd=Windows&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd" target="_blank">Windows</a>-x86_64.exe, 默认配置安装。</p><p><span style="background-color:rgb(255,255,255);">3.&nbsp; 检查安装结果。进入到windows中的命令模式:</span></p><p style="background-color:rgb(255,255,255);">(1)检测anaconda环境是否安装成功:conda --version</p><p style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615193442552?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p style="background-color:rgb(255,255,255);">(2)检测目前安装了哪些环境变量:conda info --envs</p><p style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615193459890?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p style="background-color:rgb(255,255,255);">(3) 查看当前有哪些可以使用的tensorflow版本:<strong>conda search&nbsp; --full -name tensorflow</strong></p><p><img src="https://img-blog.csdn.net/20180615193553707?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""></p><p><span style="background-color:rgb(255,255,255);">(4) 查看tensorflow包信息及依赖关系:<strong>conda&nbsp; info&nbsp; tensorflow</strong></span><br></p><p><span style="background-color:rgb(255,255,255);"><strong><img src="https://img-blog.csdn.net/2018061521501133?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></strong></span></p><p><span style="font-weight:bold;">二. 在anaconda中安装tensorflow</span></p><p><span style="background-color:rgb(255,255,255);">1.&nbsp; 进入windows命令模式,创建tfenv环境,安装python3.6:&nbsp;</span><span style="background-color:rgb(255,255,255);"><strong>conda create --name tfenv python=3.6</strong></span></p><div><img src="https://img-blog.csdn.net/20180615220036678?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></div><p><span style="background-color:rgb(255,255,255);">2 .&nbsp;<span style="background-color:rgb(255,255,255);">激活tensflow的tfenv环境: activate&nbsp; tfenv</span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615220551804?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">&nbsp; &nbsp; 检测tfenv的环境添加到了Anaconda里面:conda info --envs</span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/2018061522080997?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">看到,已经创建成功。</span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">检测当前环境中的python的版本:python --version</span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615221846949?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">退出tfenv的环境:deactivate</span><br></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615222102462?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">3.&nbsp; 在tfenv环境<a href="https://www.baidu.com/s?wd=%E4%B8%AD%E6%AD%A3%E5%BC%8F&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd" target="_blank">中正式</a>安装tensorflow包</span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">1)<span style="background-color:rgb(255,255,255);">激活tensflow的tfenv环境: activate&nbsp; tfenv</span></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">2)pip install --upgrade --ignore-installed tensorflow</span></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615222656314?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615224852188?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">3) 验证功能正常:python 进入代码环境</span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615225105865?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></span></p><pre onclick="hljs.copyCode(event)"><code class="language-python hljs"><ol class="hljs-ln"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">hello = tf.constant(<span class="hljs-string">'hello,tf'</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">sess = tf.Session()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">print(sess.run(hello))</div></div></li></ol></code><div class="hljs-button" data-title="复制"></div></pre><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><img src="https://img-blog.csdn.net/20180615225701383?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);">可以看到, 该环境下 tensorflow 工作正常。</span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="font-weight:700;">三.&nbsp; 安装可能的异常</span><br></span></span></span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"></span></span></span></span></p><p style="background-color:rgb(255,255,255);"><span><span style="color:rgb(255,0,0);">温馨提示:如果你的conda和tensorflow环境都是安装成功的,但是一用测试代码进行跑的时候就出问题了,那么注意,这个原因你由于你在安装tensorflow的时候,是直接在cmd下,而不是在你用conda激活的一个环境,所以导致,tensorflow并没有直接嵌入到conda环境,所以,就导致无法导入模块的一个错误;</span></span></p><p style="background-color:rgb(255,255,255);"><span><span style="color:rgb(255,0,0);">解决方法:(1)只需要在activate&nbsp; tfenv</span></span></p><p style="background-color:rgb(255,255,255);"><span><span style="color:rgb(255,0,0);">(2)然后再使用&nbsp;<span style="background-color:rgb(255,255,255);">pip install --upgrade --ignore-installed tensorflow&nbsp;</span>命令安装就可以了</span></span></p><p><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="background-color:rgb(255,255,255);"><span style="font-weight:700;background-color:rgb(255,255,255);">四.&nbsp; 将tensorflow嵌入到IDE中</span></span></span></span></span></p><p>这里的关键是配置后,IDE使用的python环境包含tensorflow就可以。</p><p>1. windows操作命令下设置默认python环境</p><p>可通过环境变量的顺序来设置。(这里是之前就有的python3.6.1环境和在anaconda中装的python3.6.5)</p><p><img src="https://img-blog.csdn.net/20180616100818536?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p>“系统属性”页面,点击“环境变量”&nbsp; ,选中PATH,点“编辑”</p><p><img src="https://img-blog.csdn.net/20180616100952319?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p>选中希望优先执行的python版本路径,“上移”到顶。 这里是把anaconda安装后默认在最上面,改为原来的3.6.1版本了。</p><p><img src="https://img-blog.csdn.net/20180616101110912?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p><strong>结果验证与环境切换:</strong></p><p><img src="https://img-blog.csdn.net/20180616101310565?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p><img src="https://img-blog.csdn.net/20180616101403452?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p>2.&nbsp; VSCODE里设置默认python环境 (演示设置为原来python3.6.1)<br></p><p>打开编辑器。 文件 - 首选项 - 设置</p><p>找到“用户工作区设置”,更改 python.pythonPath 配置变量即可。</p><p></p><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas, 'Courier New', monospace;font-size:14px;line-height:19px;white-space:pre;"><div> <span style="color:#9cdcfe;">"python.pythonPath"</span>: <span style="color:#ce9178;">"C:</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">Users</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">user</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">AppData</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">Local</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">Programs</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">python</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">Python36</span><span style="color:#d7ba7d;">\\</span><span style="color:#ce9178;">python.exe"</span></div><div><span style="color:#608b4e;">// "python.pythonPath": "C:\\Users\\user\\Anaconda3\\python.exe" </span></div><div></div></div>界面如下图:<p><img src="https://img-blog.csdn.net/20180616101653664?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Vienh3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt=""><br></p><p>重启vscode即可。</p> </div>
</div>
posted @
2019-01-27 13:34 
兰翔 
阅读(...) 
评论(...) 
编辑 
收藏

使用anaconda安装tensorflow (windows10环境)的更多相关文章

  1. 基于Anaconda安装Tensorflow 并实现在Spyder中的应用

    基于Anaconda安装Tensorflow 并实现在Spyder中的应用 Anaconda可隔离管理多个环境,互不影响.这里,在anaconda中安装最新的python3.6.5 版本. 一.安装 ...

  2. win10+anaconda安装tensorflow和keras遇到的坑小结

    win10下利用anaconda安装tensorflow和keras的教程都大同小异(针对CPU版本,我的gpu是1050TI的MAX-Q,不知为啥一直没安装成功),下面简单说下步骤. 一 Anaco ...

  3. 【tensorflow】1.安装Tensorflow开发环境,安装Python 的IDE--PyCharm

    ================================================== 安装Tensorflow开发环境,安装Python 的IDE--PyCharm 1.PyCharm ...

  4. 我在Suse 11 Sp3上使用anaconda安装TensorFlow的过程记录

    我在Suse 11 Sp3上使用anaconda安装TensorFlow的过程记录 准备安装包: gcc48 glibc--SP4-DVD-x86_64-GM-DVD1.iso tensorflow_ ...

  5. Ubuntu环境下Anaconda安装TensorFlow并配置Jupyter远程访问

    本文主要讲解在Ubuntu系统中,如何在Anaconda下安装TensorFlow以及配置Jupyter Notebook远程访问的过程. 在官方文档中提到,TensorFlow的安装主要有以下五种形 ...

  6. Windows环境下Anaconda安装TensorFlow的避坑指南

    最近群里聊天时经常会提到DL的东西,也有群友在学习mxnet,但听说坑比较多.为了赶上潮流顺便避坑,我果断选择了TensorFlow,然而谁知一上来就掉坑里了…… 我根据网上的安装教程,默认安装了最新 ...

  7. Windows10下通过anaconda安装tensorflow

    博主经历了很多的坎坷磨难才找到一个比较好的在win10下安装TensorFlow的方法: 首先需要说明的是如果你想通过Anaconda来安装tensorflow的话,首先要确认你的python的版本是 ...

  8. windows 下 Anaconda 安装 TensorFlow

    转自: https://www.cnblogs.com/nosqlcoco/p/6923861.html 什么是 Anaconda? Anaconda is the leading open data ...

  9. win7 使用anaconda安装tensorflow并且在jupyter notebook上启动

    记录一下学习深度学习的小事情: 1.tensorflow 现在只支持windows 64位系统: 2.因为实验室的电脑比较老旧,Gpu配置低,所以选择安装的是tensorflow Cpu版本,对于学习 ...

随机推荐

  1. 两行python代码,你是否可猜到运行结果

    两行python代码,你是否可猜到运行结果 参考: http://www.cnblogs.com/way_testlife/archive/2011/07/20/2111549.html#215689 ...

  2. 云主机搭建Kubernetes 1.10集群

    一.基础环境 云主机 下载软件包 将所有软件下载至/data目录 # 链接:https://pan.baidu.com/s/13DlR1akNBCjib5VFaIjGTQ 密码:1l69 # 链接:h ...

  3. Scan法求凸包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 给一个半径和n个点 求圆的周长 + n个点的凸包的周长 #include<bits/std ...

  4. luogu p3371 单源最短路径(dijkstral

    本来我写的对的 我就多手写了个 ios::sync_with_stdio(false); 我程序里面用了cin 还有scanf 本来想偷偷懒 我就说 我查了半天错 根本找不到的啊... 后来交了几次 ...

  5. Asp.net下拉树实现(Easy UI ComboTree)

    场景描述:某个公司有多个部门并且部门存在子部门,通过一个下拉框选取多个部门,但是如果某个部门的子部门被全部选择,则只取该部门,而忽略子部门.(叶子节点全被选中时,只取父节点) 知识点:ComboTre ...

  6. HDU 4714 Treecycle(树形dp)

    http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意:给出一棵树,删除一条边和添加一条边的代价都是1,现在要把这棵树变成环,求需要花的最小代价. 思路: ...

  7. Java实现GUI计算器【代码】

    这几天用java写了一个计算器程序,开始写的时候原本只是想实现一下GUI(这个是直接读三个字母还是什么“固椅”的发音)界面,熟悉一下Java GUI 编程,为Java期末大作业练练手,本以为代码不会很 ...

  8. HTML5-canvas实例:2D折线数据图与2D扇形图

    基础知识: <canvas id="demo" width="400" height="400"></canvas> ...

  9. STL中的map

    map 容器 提供 1 对 1 的关系 定义方式: map<string,int>mp; 写在前面的是关键字. 数据插入: 1.使用 insert 插入 pair 数据 mp.insert ...

  10. gzip压缩初探

    前言 我们平时工作中传文件时为了提高传输速度一般都会把文件压缩一下再传,那样速度回快一些,尤其是那些文件很多的文件夹,比较常用的压缩格式就是zip,rar了.那我们日常网页中利用http协议请求的那些 ...