TypeError: Descriptors cannot not be created directly.

/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/torch/utils/tensorboard/__init__.py:4: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if not hasattr(tensorboard, '__version__') or LooseVersion(tensorboard.__version__) < LooseVersion('1.15'):
Traceback (most recent call last):
File "train.py", line 15, in <module>
from logger import Logger
File "/home/zlf/data_and_code/pytorch_sac_ae-master/logger.py", line 1, in <module>
from torch.utils.tensorboard import SummaryWriter
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/torch/utils/tensorboard/__init__.py", line 10, in <module>
from .writer import FileWriter, SummaryWriter # noqa: F401
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/torch/utils/tensorboard/writer.py", line 9, in <module>
from tensorboard.compat.proto.event_pb2 import SessionLog
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/tensorboard/compat/proto/event_pb2.py", line 17, in <module>
from tensorboard.compat.proto import summary_pb2 as tensorboard_dot_compat_dot_proto_dot_summary__pb2
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/tensorboard/compat/proto/summary_pb2.py", line 17, in <module>
from tensorboard.compat.proto import tensor_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__pb2
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/tensorboard/compat/proto/tensor_pb2.py", line 16, in <module>
from tensorboard.compat.proto import resource_handle_pb2 as tensorboard_dot_compat_dot_proto_dot_resource__handle__pb2
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/tensorboard/compat/proto/resource_handle_pb2.py", line 16, in <module>
from tensorboard.compat.proto import tensor_shape_pb2 as tensorboard_dot_compat_dot_proto_dot_tensor__shape__pb2
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/tensorboard/compat/proto/tensor_shape_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "/home/zlf/anaconda3/envs/sac_ae_3.8/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
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.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

 

 

 

 

the method to solve the issue:

    pip install protobuf~=3.19.0

 

reference:

https://discuss.streamlit.io/t/typeerror-descriptors-cannot-not-be-created-directly/25639/6  

 

posted @ 2022-05-28 19:30  呦呦南山  阅读(1681)  评论(0编辑  收藏  举报