Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow在python shell中工作,但在python文件中不工作_Python_Tensorflow - Fatal编程技术网

Tensorflow在python shell中工作,但在python文件中不工作

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__' 可能的原因是什么?好吧,我犯了一个愚蠢的错误,我将正在创建的

我是Tensorflow的新手。我用pip安装了它。问题是,当我在pythonshell中输入这段代码时,它就工作了

import tensorflow as tf
print(tf.__version__)
但当我在Idle中输入相同的代码时,它会导入tensorflow模块,但在下一行中给出错误

AttributeError: module 'tensorflow' has no attribute '__version__'

可能的原因是什么?

好吧,我犯了一个愚蠢的错误,我将正在创建的文件命名为tensorflow.py,这显然与实际的tensorflow文件相冲突。这是导致错误的原因。@Mitiku的评论让我意识到了我的错误。

检查当前工作目录中是否有tensorflow.py。os.listdir(“.”)可能会帮助您。