WIN7 安装
https://www.cnblogs.com/bxyan/p/6869237.html
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