Tensor2tensor: AttributeError: module 'tensorflow' has no attribute 'flags'

Created on 26 Nov 2019  路  6Comments  路  Source: tensorflow/tensor2tensor

Description

C:\Users\XXXXX\Anaconda3\Lib\site-packages\tensor2tensor\bin>python t2t_trainer.py

Traceback (most recent call last):
  File "t2t_trainer.py", line 24, in <module>
    from tensor2tensor import models  # pylint: disable=unused-import
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\models\__init__.py", line 26, in <module>
    from tensor2tensor.models import basic
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\models\basic.py", line 25, in <module>
    from tensor2tensor.utils import t2t_model
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\t2t_model.py", line 37, in <module>
    from tensor2tensor.utils import decoding
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\decoding.py", line 41, in <module>
    FLAGS = tf.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'flags'

Environment information

OS: Windows 10 - 64bit

$ pip freeze | grep tensor
tensor2tensor==1.15.2
tensorboard==2.0.1
tensorflow==2.0.0
tensorflow-datasets==1.3.0
tensorflow-estimator==2.0.1
tensorflow-gan==2.0.0
tensorflow-gpu==2.0.0
tensorflow-hub==0.7.0
tensorflow-metadata==0.15.1
tensorflow-probability==0.7.0
tf-estimator-nightly==2.0.0.dev2019111709
tf-nightly-gpu==2.1.0.dev20191117

$ python -V

Python 3.7.4

$ conda info

     active environment : None
       user config file : C:\Users\XXXX\.condarc
 populated config files :
          conda version : 4.7.12
    conda-build version : 3.18.9
         python version : 3.7.4.final.0
       virtual packages : __cuda=10.2
       base environment : C:\Users\XXXX\Anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\XXXX\Anaconda3\pkgs
                          C:\Users\XXXX\.conda\pkgs
                          C:\Users\XXXX\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\XXXX\Anaconda3\envs
                          C:\Users\XXXX\.conda\envs
                          C:\Users\XXXX\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False

Steps to reproduce:

With tensorflow-gpu-nightly installed on a win10 64 bit - simply navigate to
\Anaconda3\Lib\site-packages\tensor2tensor\bin
and type
python t2t_{{any_file}}.py

Error logs:

  File "C:\Users\XXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\decoding.py", line 41, in <module>
    FLAGS = tf.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'flags'

Most helpful comment

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

Seems like there's a 'v1' in it for TF 2.0: tf.compat.v1.flags.Flag

All 6 comments

Maybe T2T doesn't support tensorflow2.0 yet.

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

Seems like there's a 'v1' in it for TF 2.0: tf.compat.v1.flags.Flag

i get this error in tf 1.13.1. what is the issue?

i get this error in tf 1.13.1. what is the issue?

I had met same error in tf1.13 , have you solved this error?

i get this error in tf 1.13.1. what is the issue?

I had met same error in tf1.13 , have you solved this error?

I had the same error in tf 1.13.1, and solved it by renaming my own module which has the same name with a site package (logging)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goodmansasha picture goodmansasha  路  4Comments

zzkszzks picture zzkszzks  路  5Comments

jhyoocoder picture jhyoocoder  路  3Comments

activatedgeek picture activatedgeek  路  4Comments

jsawruk picture jsawruk  路  4Comments