1、打開Anaconda Prompt
2、搭建TensorFlow的環境:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes conda create -n tensorflow python=3.5
3、在用戶目錄下找到文件 .condarc
環境搭建完成:
4、安裝(CPU)版的TensorFlow:
// 啟動TensorFlow: activate tensorflow
conda install tensorflow
5、測試TensorFlow是否安裝完成
終端進入python:
輸入:
import tensorflow as tf hello = tf.constant("hello, tensorflow!") sess = tf.Session() print(sess.run(hello))輸出: b'hello, tensorflow!',即成功!!!
6、在Jupiter中使用TensorFlow
准備工作:
- 安裝ipython,安裝jupyter
conda install ipython conda install jupyter- 輸入:
ipython kernelspec install-self --user- 看到類似這個結果
Installed kernelspec python3 in C:\Users\XXX\Jupyter\kernels\python3 即可以了!打開Anaconda Jupiter 稍等一會
復制網址,瀏覽器打開
新建python3文件
輸入:
import tensorflow as tf tf.__version__輸出:
即安裝成功!
7、安裝成功后,每次使用 TensorFlow 的時候都需要激活 conda 環境
//查看環境 conda info --envs //激活環境 activate tensorflow //關閉環境 deactivate tensorflow








