5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TensorFlow 2 で module 'tensorflow' has no attribute 'app' エラーが出る

Last updated at Posted at 2020-04-14

git clone してきたプログラムを、tensorflow 2 で動かそうとすると、module 'tensorflow' has no attribute 'app' エラーが出たときの解消(してない?)方法です。

エラー

とあるプログラムを Github からクローンして動かそうとするとエラーが出るので、試しに手で打ってみても同じくエラー。

>>> import tensorflow as tf
>>> tf.app.flag
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'app'

ちょっと調べてみたら原因はすぐにわかった。

原因:V2 ではすでに削除されている・・・

in this tensorflow 2 guide, https://www.tensorflow.org/guide/effective_tf2, it says tf.app is removed.

解決方法

アンインストールして、バージョン1の新しそうなのを入れました、解決(違う)。

pip uninstall tensorflow
pip install tensorflow==1.15
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?