module 'tensorflow' has no attribute 'app'怎么解决
时间: 2023-06-18 14:08:58 浏览: 890
这个问题可能是因为你的 TensorFlow 版本过低,而 `app` 模块在新版 TensorFlow 中已经被移除了。你可以尝试升级 TensorFlow 到最新版本或者使用其他模块代替 `app`。
如果你使用的是 TensorFlow 1.x 版本,那么可以尝试安装 `tensorflow-serving-api` 模块,然后将 `import tensorflow as tf` 更改为 `import tensorflow.compat.v1 as tf`,并在代码中使用 `tf.app` 替换为 `tf.compat.v1.app`。
如果你使用的是 TensorFlow 2.x 版本,那么你可以使用 `argparse` 模块代替 `app`,例如:
```
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--data_dir', type=str, default='./data')
args = parser.parse_args()
```
这样就可以解决该问题。