TensorFlow安裝(win7 64位+python3.6)及問題
阿新 • • 發佈:2019-01-02
1、安裝python
首先安裝python。cmd下輸入 python --version 可以檢視python版本。我的版本是3.6.2
2、安裝TensorFlow
直接使用pip命令進行安裝。安裝映象選擇清華大學的源。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.3.0rc0-cp36-cp36m-win_amd64.whl
安裝中
安裝成功
3、驗證
輸入以下命令
如果安裝成功的話會輸出import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
Hello, TensorFlow!
cmd的python環境下:
pycharm下:
問題:
1)之前在有些資料中
pip3 install --upgrade tensorflow
pip3 install --upgrade tensorflow-gpu
通過這兩個命令分別安裝了CPU版本和GPU版本的TensorFlow,結果輸入 import tensorflow as tf 時輸出錯誤:
module 'tensorflow' has no attribute 'constant'
問題:
這是同時安裝了CPU和GPU或者同時安裝後解除安裝了其中一個版本造成的。
解決辦法:
pip uninstall *** 解除安裝兩個版本的TensorFlow,再重新安裝需要的版本。
參考部落格:
https://blog.csdn.net/z4909801/article/details/78070991
https://blog.csdn.net/evaljy/article/details/70209957