【发布时间】:2017-10-25 06:41:50
【问题描述】:
我正在尝试运行我使用的示例脚本
import tensorflow as tf
def main():
if __name__ = '__main__':
tf.app.run(main = main)
引发错误:
AttributeError: module 'tensorflow' has no attribute 'app'
但是当我运行它时:
from tensorflow.python.platform import app
它运行良好..我使用的python版本是3.6.1和tensorflow版本:0.1.8
其实还是
print(tf.__version__)
显示属性错误..
AttributeError: module 'tensorflow' has no attribute '__version__'
【问题讨论】:
-
print(dir(tf)) 的输出是什么?
-
这是输出:['doc', 'loader', 'name', 'package', 'path', 'spec', 'core', 'python']
-
这些不是 tensorflow 的属性。您可能在工作目录中有名为 tensorflow.py 的文件。请检查
-
dir /s tensorflow.py 列出的文件总数:3 个文件全部命名为:pywrap_tensorflow.py
-
您可以更改您的工作目录并从那里尝试吗?
标签: python tensorflow python-3.6