Tensorflow在python shell中工作,但在python文件中不工作
我是Tensorflow的新手。我用pip安装了它。问题是,当我在pythonshell中输入这段代码时,它就工作了Tensorflow在python shell中工作,但在python文件中不工作,python,tensorflow,Python,Tensorflow,我是Tensorflow的新手。我用pip安装了它。问题是,当我在pythonshell中输入这段代码时,它就工作了 import tensorflow as tf print(tf.__version__) 但当我在Idle中输入相同的代码时,它会导入tensorflow模块,但在下一行中给出错误 AttributeError: module 'tensorflow' has no attribute '__version__' 可能的原因是什么?好吧,我犯了一个愚蠢的错误,我将正在创建的
import tensorflow as tf
print(tf.__version__)
但当我在Idle中输入相同的代码时,它会导入tensorflow模块,但在下一行中给出错误
AttributeError: module 'tensorflow' has no attribute '__version__'
可能的原因是什么?好吧,我犯了一个愚蠢的错误,我将正在创建的文件命名为tensorflow.py,这显然与实际的tensorflow文件相冲突。这是导致错误的原因。@Mitiku的评论让我意识到了我的错误。检查当前工作目录中是否有tensorflow.py。os.listdir(“.”)可能会帮助您。