TensorFlow学习笔记(2)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
    原文作者:谢昆明
    原文地址: https://www.jianshu.com/p/6cc2f2ec6fca
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞