下載安裝Anaconda
首先下載Anaconda,可以從清華大學的鏡像網站進行下載。
安裝Anaconda,注意安裝時不要將添加環境變量的選項取消掉。
安裝完成之后,在安裝目錄下cmd,輸入
conda list
可以查看Anaconda為我們提供的集成環境:
下面只是一部分截圖:
查看版本信息:
conda --version
Anaconda 安裝成功。
接下來需要設置 Anaconda 倉庫鏡像,因為默認連接的是國外鏡像地址,下載速度比較慢,我們把鏡像地址改為清華大學開源軟件鏡像站,Anaconda Prompt 窗口輸入:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
安裝 TensorFlow
繼續在 Anaconda Prompt 窗口輸入:
conda create -n tensorflow python=3.5
表示創建 TensorFlow 依賴環境,TensorFlow 目前不支持Python3.6,這里我們使用Python3.5。
控制台輸出:
Fetching package metadata ............... Solving package specifications: . Package plan for installation in environment D:\Program Files\anaconda\envs\tensorflow: The following NEW packages will be INSTALLED: pip: 9.0.1-py35_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
python: 3.5.3-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
setuptools: 27.2.0-py35_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
vs2015_runtime: 14.0.25123-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
wheel: 0.29.0-py35_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
Proceed ([y]/n)? y
提示我們安裝哪些依賴軟件,輸入‘y’,回車。
安裝 CPU 版本:
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
激活環境:
activate tensorflow
退出環境:
deactivate tensorflow
測試
進入到 Anaconda 安裝目錄下 /envs /tensorflow 文件夾,繼續在 Anaconda Prompt 窗口輸入輸入:
python.exe
輸入:
>>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> sess.run(hello) b'Hello, TensorFlow!'