在anaconda中安装tensorflow

打开Anaconda Prompt,

step1: 输入清华仓库镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

step2: 搭建tensorflow环境

输入conda create -n tensorflow python=3.5

结束后anaconda中的environment中可以看到tensorflow,

step3: 输入activate tensorflow

(切换到该环境)

step4:安装cpu版本的TensorFlow

输入pip install --upgrade --ignore-installed tensorflow
开始安装,网速快的话5分钟左右就ok!!


安装好了 successfully .....

step5: 测试tensorflow
在Anaconda Prompt中启动tensorflow环境,并进入python环境

输入代码:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

显示结果如下, 说明已经成功.

 关键!!!在spyder中 'import tensorflow' 提示错误...why??  显示No module named ‘tensorflow’

在anaconda navigator的environment  tensorflow中,上方的菜单中选择 Not installed ,搜索spyder, (我这里已经install好了,因此搜不到了)

选择spyder, 在右下方有apply, 安装一下插件, for about 5分钟 

最后在installed 中可以发现已经有了spyde, 接下来就可以在spyder中使用了!!




猜你喜欢

转载自www.cnblogs.com/xuying-fall/p/8926852.html