安裝好 anaconda後,即可通過anaconda安裝tensorflow
steps specially:
1.創建虛擬環境
(爲Anaconda創建一個python3.5(或者3.6都行,隨便)的環境,環境名稱爲tensorflow ,輸入下面命令)
conda
create -n tensorflow pip python=3.6
2.激活環境 (不使用時關閉環境)
source
activate tensorflow (source
deactivate tensorflow)
3.安裝TensorFlow (cpu版本的)
pipinstall--upgrade--ignore-installedtensorflow
4.運行test.py驗證腳本
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
運行 no errors 即 install success
//如何不激活環境即可使用tensorflow環境
#退出tensorflow環境source deactivate tensorflow
#運行pip install tensorflow
pipinstall --upgrade pip