'Tensorflow compatible version for gfile

I have a Python code which uses Tensorflow module as

from tensorflow import gfile

However, with the following tf module versions

tb-nightly                     2.9.0a20220218
tensorboard-data-server        0.6.1
tensorboard-plugin-wit         1.8.1
tensorflow-io-gcs-filesystem   0.24.0
termcolor                      1.1.0
tf-estimator-nightly           2.9.0.dev2022021709
tf-nightly-gpu                 2.9.0.dev20220218

I get this error

  File "loop_init.py", line 21, in <module>
    import main
  File "/research/reinforcement/minigo/main.py", line 31, in <module>
    from tensorflow import gfile
ImportError: cannot import name 'gfile' from 'tensorflow' (/usr/local/lib/python3.8/dist-packages/tensorflow/__init__.py)

Seems like a version mismatch. So, I wonder which Tensorflow version works with gfile. Any idea about that?



Solution 1:[1]

gfile api is available inside tensorFlow.io module. So you need to use below namespace to import this api:

from tensorflow.io import gfile

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TFer2