解决ImportError: No module named google.protobuf

Bug场景:

Windows环境,Pytorch:1.10.0,使用tensorboard时发生如下错误

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


解决方案:

网上比较多的方法如下(但并未奏效)

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

在github上看到有人提到相关问题:参考链接

看来是protobuf在python3上的版本问题,重新安装protobuf的版本:

pip install protobuf==3.19

你可能感兴趣的:(Debug,pytorch,深度学习,debug,tensorboard)