Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

AttributeError: module 'tensorflow' has no attribute 'flags' #1754

Open
birdmw opened this issue Nov 26, 2019 · 10 comments
Open

AttributeError: module 'tensorflow' has no attribute 'flags' #1754

birdmw opened this issue Nov 26, 2019 · 10 comments

Comments

@birdmw
Copy link

birdmw commented Nov 26, 2019

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'
@Mr-wang2016
Copy link

Maybe T2T doesn't support tensorflow2.0 yet.

@RamoxCode
Copy link

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

@paklui
Copy link

paklui commented Jan 2, 2020

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

@poojitharamachandra
Copy link

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

@ericosmic
Copy link

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?

@cszipper
Copy link

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)

@sisrfeng
Copy link

I had some local (non-Conda) Tensorflow packages still installed, which were higher priority in the python environment

Just rm -r each tensorflow package in your ~/.local/ library and reinstall the conda environment.

@dave1996-13
Copy link

tf.compat.v1.flags.Flag
Actually, it is FLAGS at the end to be precise in tf2

@HaithemH
Copy link

HaithemH commented Oct 5, 2022

I had the same error did you solved this?

@Jeff-Winchell
Copy link

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

Actually, it is tf.compat.v1.flags

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests