import error with protobuf==4.21.0
See original GitHub issue🐛 Bug
import error when using new protobuf version
To Reproduce
pip install pytorch_lightning protobuf
python
import pytorch_lightning as pl
Results
import pytorch_lightning as pl
/usr/local/lib/python3.9/site-packages/pytorch_lightning/__init__.py:30: in <module>
from pytorch_lightning.callbacks import Callback # noqa: E402
/usr/local/lib/python3.9/site-packages/pytorch_lightning/callbacks/__init__.py:26: in <module>
from pytorch_lightning.callbacks.pruning import ModelPruning
/usr/local/lib/python3.9/site-packages/pytorch_lightning/callbacks/pruning.py:[31](https://github.com/openclimatefix/nowcasting_forecast/runs/6607770425?check_suite_focus=true#step:4:32): in <module>
from pytorch_lightning.core.lightning import LightningModule
/usr/local/lib/python3.9/site-packages/pytorch_lightning/core/__init__.py:16: in <module>
from pytorch_lightning.core.lightning import LightningModule
/usr/local/lib/python3.9/site-packages/pytorch_lightning/core/lightning.py:40: in <module>
from pytorch_lightning.loggers import LightningLoggerBase, LoggerCollection
/usr/local/lib/python3.9/site-packages/pytorch_lightning/loggers/__init__.py:18: in <module>
from pytorch_lightning.loggers.tensorboard import TensorBoardLogger
/usr/local/lib/python3.9/site-packages/pytorch_lightning/loggers/tensorboard.py:26: in <module>
from torch.utils.tensorboard import SummaryWriter
/usr/local/lib/python3.9/site-packages/torch/utils/tensorboard/__init__.py:10: in <module>
from .writer import FileWriter, SummaryWriter # noqa: F401
/usr/local/lib/python3.9/site-packages/torch/utils/tensorboard/writer.py:9: in <module>
from tensorboard.compat.proto.event_pb2 import SessionLog
/usr/local/lib/python3.9/site-packages/tensorboard/compat/proto/event_pb2.py:17: in <module>
from tensorboard.compat.proto import summary_pb2 as tensorboard_dot_compat_dot_proto_dot_summary__pb2
/usr/local/lib/python3.9/site-packages/tensorboard/compat/proto/summary_pb2.py:17: in <module>
from tensorboard.compat.proto import tensor_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__pb2
/usr/local/lib/python3.9/site-packages/tensorboard/compat/proto/tensor_pb2.py:16: in <module>
from tensorboard.compat.proto import resource_handle_pb2 as tensorboard_dot_compat_dot_proto_dot_resource__handle__pb2
/usr/local/lib/python3.9/site-packages/tensorboard/compat/proto/resource_handle_pb2.py:16: in <module>
from tensorboard.compat.proto import tensor_shape_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__shape__pb2
/usr/local/lib/python3.9/site-packages/tensorboard/compat/proto/tensor_shape_pb2.py:[36](https://github.com/openclimatefix/nowcasting_forecast/runs/6607770425?check_suite_focus=true#step:4:37): in <module>
_descriptor.FieldDescriptor(
/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py:[56](https://github.com/openclimatefix/nowcasting_forecast/runs/6607770425?check_suite_focus=true#step:4:57)0: in __new__
_message.Message._CheckCalledFromGeneratedFile()
E TypeError: Descriptors cannot not be created directly.
E If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
E If you cannot immediately regenerate your protos, some other possible workarounds are:
E 1. Downgrade the protobuf package to 3.20.x or lower.
E 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
E
E More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
Expected behavior
No import error
Environment
- PyTorch Lightning Version (e.g., 1.5.0): pytorch-lightning-1.6.3
- PyTorch Version (e.g., 1.10): torch-1.11.0
- Python version (e.g., 3.9): 3.9
- OS (e.g., Linux): from docker image
python:3.9-slim
- CUDA/cuDNN version:
- GPU models and configuration: CPU
- How you installed PyTorch (
conda
,pip
, source): pip - If compiling from source, the output of
torch.__config__.show()
: - Any other relevant information: I also get this error on my macbook
Additional context
Filed on this github action
Issue Analytics
- State:
- Created a year ago
- Reactions:11
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Breaking change in protobuf v4.21.0-rc1 breaks `import ...
Issue Type Bug Source binary Tensorflow Version tf 2.9.0-rc2 Custom Code No OS Platform and Distribution Linux Ubuntu 20.04 Mobile device No ...
Read more >python - google.protobuf import error - Stack Overflow
I am encountering: ImportError: No module named google.protobuf. I am working with virtual environments. I have used pip to install protobuf ...
Read more >Error "protobuf Import" Is Reported on the Python Dependency ...
During use of MindConverter, '_message' cannot be imported from the google.protobuf.pyext package, as shown in Figure 1.Re-build protobuf.
Read more >Why do I see “cannot import name descriptor_pb2” error?
to Protocol Buffers. Hi all, I'm having some trouble using our generated Python class... I posted my question on SO:
Read more >COCO Detection with TensorFlow - Kaggle
import numpy as np import pandas as pd import tensorflow as tf from PIL import Image from matplotlib import ... This will become...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems so. For anyone seeing this issue, a quick workaround is to downgrade
protobuf
version as shown in the error:EDIT on June 9, 2022: Upgrading
tensorboard
to 2.9.1 or later should also work:@adamjstewart Thank you very much for the information! I’ll keep this issue open so that we do something before it breaks our CI again.