系统:win7 x64
1、安装python3.5.2
网上查阅了资料表明,TensorFlow与python3.6版本安装时会出各种问题,所以为省事,本次安装python3.5版本。
2、安装Anaconda(为什么安装这个自行百度)
3、安装TensorFlow
安装TensorFlow时需从Anaconda仓库下载,由于默认链接为国外镜像,所以下载速度非常慢,这里先修改为国内清华镜像地址。
打开“Anaconda Prompt”分别执行以下代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
接下来安装TensorFlow
conda create -n tensorflow python=3.5.2
正常情况如下:
等待提示输入,然后输入“y”
最后完成后是这个样子
键入“activate tensorflow” 激活即可。
紧接着输入:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
等待安装完成。
4、测试:
安装完成后输入 python
进入python后输入:
import tensorflow as tf
sess = tf.Session()
a = tf.constant(10)
b= tf.constant(12)
print(sess.run(a+b))
运行没问题即表示环境搭建成功。
5、注意事项
安装过程若提示pip版本问题,请执行以下代码更新pip版本
python -m pip install --upgrade pip