首先安装anaconda,安装时注意添加路径
接着打开
我下的是最新版本的anaconda 默认3.7版本的python,但是tensorflow对3.6版本的python支持比较好,所以要先conda一个tensorflow环境。直接create这个环境会很慢,所以先改为清华镜像的conda
Anaconda 镜像使用帮助
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
接着就可以输入conda create -n tensorflow python=3.6,会安装一个python3.6版本的名为tensorflow的虚拟环境。
接着activate tensorflow 进入tensorflow的环境
然后pip tensorflow,tensorflow官方是推荐直接pip的
直接改用清华镜像去pip pypi 镜像使用帮助
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
静静等待安装完成,安装好后打开anaconda navigator,将base改为tensorflow,个人习惯用jupyter,install一个自己喜欢的解释器就好了。
最后运行一段tensorflow测试代码
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
输出