ImportError: No module named tensorflow

导入tensorflow模块失败,

with python2

pip show tensorflow 检查是否安装

python test.py 测试

with python3

pip3 show tensorflow 检查是否安装

python3 test.py 测试

test.py

import tensorflow as tf
import numpy as np

c = np.array([[3.,4], [5.,6], [6.,7]])
step = tf.reduce_mean(c, 1)                                                                                 
with tf.Session() as sess:
    print(sess.run(step))

如果安装的是tensorflow的模块是python3的,那运行python test.py就会报错,必须运行python3 test.py

ImportError: No module named tensorflow
发布了758 篇原创文章 · 获赞 35 · 访问量 60万+

猜你喜欢

转载自blog.csdn.net/kelsel/article/details/83690171