一、安裝Python3.6.8
https://www.python.org/downloads/windows/ 打開網址,找到合適的安裝包,我用的是64位
- Download Windows x86-64 executable installer
爲了省事兒可以在安裝第一頁下面勾選“Add Path”
驗證:cmd命令行輸入
python --version
二、安裝TensorFlow
pip install tensorflow
到這裏要是成功完事兒了的話,直接轉“四、測試TensorFlow”
——————————分割線———————————
二、安裝Anaconda
這個一定要和python的版本相對應,可以參考https://blog.csdn.net/yuejisuo1948/article/details/81043823
我用的是anaconda3-5.2.0,下載地址https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
也建議勾選“Add Anaconda to my Path”
驗證:cmd命令行輸入
conda --version
三、安裝TensorFlow
在window搜索處輸入
Anaconda Prompt
選擇,打開命令行界面(本文後續全部操作都在這個窗口中進行),輸入
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
修改鏡像地址到國內清華。
安裝TensorFlow,後面的版本號根據你自己本機上python的版本設置:
conda create -n tensorflow python=3.6.8
等待一下,輸入“y”:
完成安裝後,輸入
pip install -I https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.3.0rc0-cp36-cp36m-win_amd64.whl
注意pip的選項中使用大寫的“I”。
這樣表示安裝成功。
但是也可能會報錯:
(1)問題1
distributed 1.21.8 requires msgpack, which is not installed.
輸入:
pip install msgpack-python
pip install msgpack
(2)問題2
ERROR: tensorflow-tensorboard 1.5.1 has requirement bleach==1.5.0, but you'll have bleach 2.1.3 which is incompatible.
ERROR: tensorflow-tensorboard 1.5.1 has requirement html5lib==0.9999999, but you'll have html5lib 1.0.1 which is incompatible.
輸入:
pip install tensorflow-tensorboard
四、測試TensorFlow
在Anaconda Prompt窗口中輸入
python
進入python後,輸入
import tensorflow as tf
sess = tf.Session()
a = tf.constant(10)
b= tf.constant(12)
sess.run(a+b)
運行成功:
如果在import(劃紅線處)出現下述報錯:
ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['E:\\Anaconda3\\lib\\site-packages\\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.
表示這時候電腦上numpy新舊版本同時存在,有衝突,需要重裝,重複輸入:
pip uninstall numpy
直到電腦上的numpy全部卸載乾淨,提醒:
WARNING: Skipping numpy as it is not installed.
再重新安裝:
pip install numpy
完成後則繼續測試。
五、參考引用
https://www.cnblogs.com/lvsling/p/8672404.html
https://blog.csdn.net/goodbrat/article/details/81108313