问题描述
当在命令行窗口安装完成Tensorflow之后,想要使用PyCharm编译器来运行,但是却被报错提醒ImportError: No module named tensorflow
经过探索研究,发现要重新设置PyCharm的编译环境。
解决方法
步骤如下:
1.打开PyCharm软件, 进入File->Settings目录

2.在Project Interpreter一行点击“设置”按钮

3.选择Add Local,添加本地环境

选择当时安装Tensorflow的Python35环境下即可
这样就可以解决没有找到Tensorflow module的问题了,如图所示:

运行一个小程序,计算向量和:
import tensorflow as tf
a=tf.constant([1.0,2.0],name="a")
b=tf.constant([2.0,3.0],name="b")
result = a+b
print(result)
sess=tf.Session()
print(sess.run(result))
sess.close()
运行结果:

完成!
本文介绍了解决在PyCharm中导入TensorFlow模块失败的问题。通过调整编译环境,确保已安装的TensorFlow能被正确识别。此外,还提供了一个简单的TensorFlow程序示例。

2万+

被折叠的 条评论
为什么被折叠?



