Tensorflow安装教程

安装3.6.8版本的python

⦁ 按图所示操作
Tensorflow安装教程
Tensorflow安装教程
⦁ 在cmd控制台窗口中键入pip list
Tensorflow安装教程
⦁ 输入pip uninstall tensorflow后将卸载掉tensorflow
⦁ 再cmd控制台窗口中键入如下图所示命令
Tensorflow安装教程

⦁ 安装后再在cmd控制台窗口下键入python进入python环境
⦁ 输入下面代码后出错
import tensorflow as tf
hello = tf.constant(‘hello,tensorf’)
sess = tf.Session()
print(sess.run(hello))
⦁ 出现错误AttributeError: module ‘tensorflow’ has no attribute ‘Session’
⦁ sess=tf.Session()更正为:
⦁sess=tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
⦁ 再次出现错误:
⦁ 把上述代码为下述代码后成功输出:
import tensorflow as tf
hello=tf.constant(‘hello world’)
print(hello)
print(hello.numpy())
17.pip install –upgrade tensorflow==1.0