1. ホーム

AttributeError: module tensorflow no attribute app Solution

2022-02-21 02:55:09

これはtensorflowのバージョンのせいです。私の記憶が間違っていなければ、あなたはtensorflow2.0を使っていて、ソースコードはtensorflow1.0です。だからエラーになるんだ。

回避策 (1)

import tensorflow as tf to import tensorflow.compat.v1 as tf
        (2) use tf.compat.v1.flags

交換

tf.app.flags
Both of these methods work. Personally, I recommend the first one.
If you have tried both methods and still have not solved the problem, you have to take out the necessary skills, download pycharm, select the python version, create a corresponding virtual environment for python in pycharm, if the original is tensorflow 2.0 version uninstall, install tensorflow 1.x version. Remember to check the specific version to install it.