[Problem record] AttributeError: module 'tensorflow' has no attribute 'io'

from torch.utils.tensorboard import SummaryWriter

Encountered an error:

File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 220, in __init__
    self._get_file_writer()
  File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 251, in _get_file_writer
    self.flush_secs, self.filename_suffix)
  File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 61, in __init__
    log_dir, max_queue, flush_secs, filename_suffix)
  File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\tensorboard\summary\writer\event_file_writer.py", line 72, in __init__
    tf.io.gfile.makedirs(logdir)
  File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__
    return getattr(load_once(self), attr_name)
AttributeError: module 'tensorflow' has no attribute 'io'

Although Pytorch directly uses tensorboard, it still needs to be used with tensorflow. The solution:

pip install tensorflow==2.0

problem solved!

Guess you like

Origin blog.csdn.net/Calistar/article/details/125564705