win7 64位 anaconda4.4 安装tensorflow cpu

<div id="article_content" class="article_content csdn-tracking-statistics tracking-click" data-mod="popu_519" data-dsm="post" style="overflow: hidden;">
                            <div class="markdown_views" deep="4">
                        <p>*</p>






<h2 id="在win7下安装tensorflow-cpu"><em>在Win7下安装TensorFlow  cpu*</em></h2>


<p>参考了tensorflow的安装教程和网上的部分博客,结合自己安装时出现的问题,写了如下的步骤,刚刚接触 水平有限,请多多读指教</p>


<p><strong>一、如何安装TensorFlow</strong> <br data-filtered="filtered">
安装方法以下两种 <br data-filtered="filtered">
“native” pip <br data-filtered="filtered">
Anaconda</p>


<ul>
<li><p>Native pip</p>


<p><strong>Native pip</strong>在您的系统上直接安装TensorFlow,而无需通过虚拟环境,pip安装可能会干扰系统上其他基于Python的安装。但是,如果了解pip和Python环境,”native” pip安装通常只需要一个命令!此外,如果使用”native” pip,用户可以从系统上的任何目录运行TensorFlow程序。</p></li>
<li><p>Anaconda <br data-filtered="filtered">
   在<strong>Anaconda</strong>中,您可以使用conda创建虚拟环境。但是,在Anaconda内,建议使用pip install命令安装TensorFlow ,而不是使用该conda install命令。</p></li>
</ul>


<p>注意: conda包是社区支持的,没有正式支持。也就是说,TensorFlow团队既不测试也不维护这个conda包。使用该包,自己承担风险。</p>


<p><strong>二、用native” pip</strong> <br data-filtered="filtered">
首先安装Python3.6版本 <br data-filtered="filtered">
在cmd执行 pip install命令。要安装仅限CPU版本的TensorFlow,请输入以下命令:</p>






<pre class="prettyprint"><code class="hljs cmake has-numbering">pip <span class="hljs-keyword">install</span> tensorflow</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p><strong>三、anaconda安装</strong> <br data-filtered="filtered">
1.  下载 anaconda 4.4  网址:<a href="https://www.continuum.io/downloads" target="_blank">https://www.continuum.io/downloads</a> <br data-filtered="filtered">
安装 选择安装路径  添加环境变量 点击下一步</p>


<ol>
<li>通过调用以下命令创建一个名为tensorflow的conda环境:</li>
</ol>






<pre class="prettyprint"><code class="hljs fix has-numbering"><span class="hljs-attribute">conda create -n tensorflow python</span>=<span class="hljs-string">3.6 </span></code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p>将要安装一下packages yes or no?  输入y 回车 如下图</p>


<p><img src="https://img-blog.csdn.net/20170819201421251?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>打开 anaconda  navigator 即可发现已添加的 tensorflow环境,</p>


<p>我在打开navigator时出现以下错误 it could not find or load the Qt platform plugin “windows”  <br data-filtered="filtered">
<img src="https://img-blog.csdn.net/20170819201515733?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>参考<a href="http://blog.csdn.net/isomebody/article/details/72910207" target="_blank">http://blog.csdn.net/isomebody/article/details/72910207</a> <br data-filtered="filtered">
将\Anaconda3\Library\plugins目录下的platforms文件夹拷贝到\Anaconda3后重新打开Anaconda Navigator</p>


<p><img src="https://img-blog.csdn.net/20170819201612270?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>创建tensorflow环境成功   </p>


<p>3.进入 tensorflow环境  输入</p>


<pre class="prettyprint"><code class="hljs applescript has-numbering"><span class="hljs-command">activate</span> tensorflow</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p>(退出 输入 deactivate tensorflow) <br data-filtered="filtered">
结果如下图 <br data-filtered="filtered">
<img src="https://img-blog.csdn.net/20170819201705733?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>4.安装tensorflow (cpu版)`输入</p>






<pre class="prettyprint"><code class="hljs cmake has-numbering">pip <span class="hljs-keyword">install</span> tensorflow</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p><img src="https://img-blog.csdn.net/20170819201857105?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>5、  测试是否安装成功 <br data-filtered="filtered">
如果您通过Anaconda安装,请激活您的Anaconda环境。调用python 输入:<code>python</code>   (退出 输入 ctrl+z) <br data-filtered="filtered">
输入以下短程序:</p>






<pre class="prettyprint"><code class="hljs python has-numbering"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
hello = tf.constant(<span class="hljs-string">'Hello, TensorFlow!'</span>)
sess = tf.Session()
print(sess.run(hello))
</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li></ul></pre>


<p>如果系统输出以下内容,则安装成功</p>






<pre class="prettyprint"><code class="hljs  has-numbering">Hello,TensorFlow!</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p><img src="https://img-blog.csdn.net/20170819202111906?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>其中提示……could speed up cpu computations 百度是警告信息 没有过多影响 就忽视了</p>


<p><strong>6.    安装tensorflow环境下的 spyder 和ipython</strong> <br data-filtered="filtered">
    如果直接打开anaconda下的spyder 输入 import tensorflow as tf  会提示 No module named ‘tensorflow’ 所以安装tensorflow环境下的spyder ,方法如下</p>


<p>在anaconda prompt中输入 </p>






<pre class="prettyprint"><code class="hljs applescript has-numbering"><span class="hljs-command">activate</span> tensorflow</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p>进入tensorflow环境(已经在此环境下的忽略)在tensorflow环境中安装anaconda  输入</p>






<pre class="prettyprint"><code class="hljs cmake has-numbering"> conda <span class="hljs-keyword">install</span> anaconda</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li></ul></pre>


<p>(在网上看到有两种方式 <br data-filtered="filtered">
a.打开navigator 在home–applications on–tensorflow 然后找到spyder模块点击install   尝试未成功 <br data-filtered="filtered">
b.通过命令语句conda install spyder (conda install ipython) 安装ipython       尝试也没有成功 提示错误信息 </p>






<pre class="prettyprint"><code class="hljs lua has-numbering">ERRORconda.core.link:_execute_actions(<span class="hljs-number">337</span>): An <span class="hljs-built_in">error</span> occurred <span class="hljs-keyword">while</span> installing
<span class="hljs-built_in">package</span> <span class="hljs-string">'defaults::qt-5.6.2-vc14_6'</span>.
</code><ul class="pre-numbering"><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li></ul></pre>


<p><img src="https://img-blog.csdn.net/20170819202344208?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>最终conda install anaconda 安装了tensorflow环境下的 spyder 和ipython 如图<img src="https://img-blog.csdn.net/20170819202425105?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>在 spyder中测试如下</p>


<p><img src="https://img-blog.csdn.net/20170819202546547?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzM0MTQ3MDc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>


<p>参考 <br data-filtered="filtered">
<a href="https://www.tensorflow.org/install/install_windows" target="_blank">https://www.tensorflow.org/install/install_windows</a> <br data-filtered="filtered">
<a href="https://www.zhihu.com/question/49144687" target="_blank">https://www.zhihu.com/question/49144687</a> <br data-filtered="filtered">
<a href="https://github.com/conda/conda/issues/4582" target="_blank">https://github.com/conda/conda/issues/4582</a> <br data-filtered="filtered">
<a href="http://blog.csdn.net/sunxinyu/article/details/73255802" target="_blank">http://blog.csdn.net/sunxinyu/article/details/73255802</a></p>                </div>
                                                <link rel="stylesheet" href="http://csdnimg.cn/release/phoenix/production/markdown_views-0bc64ada25.css">
                                    </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值