解决ImportError: No module named google.protobuf

Bug scene:

Windows environment, Pytorch: 1.10.0, the following error occurs when using tensorboard

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py", line 2, in <module>
    from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
  File "/usr/local/lib/python3.7/site-packages/tensorboard/summary/__init__.py", line 33, in <module>
    from tensorboard.summary._output import DirectoryOutput  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/tensorboard/summary/_output.py", line 17, in <module>
    from tensorboard.compat.proto import event_pb2
  File "/usr/local/lib/python3.7/site-packages/tensorboard/compat/proto/event_pb2.py", line 7, in <module>
    from google.protobuf.internal import enum_type_wrapper
ModuleNotFoundError: No module named 'google.protobuf'


solution:

There are many methods on the Internet as follows (but it didn't work)

pip uninstall protobuf
pip uninstall google
pip install google
pip install protobuf

I saw someone mention related issues on github: reference link

It seems to be a version problem of protobuf on python3, reinstall the version of protobuf:

pip install protobuf==3.19

Guess you like

Origin blog.csdn.net/lzzzzzzm/article/details/130770163