python protobuf: incomplete _pb2.py file?

511 views
Skip to first unread message

Nelson Meyer

unread,
Oct 25, 2022, 6:22:42 AM10/25/22
to Protocol Buffers
Hi everyone,
I hope, this is the right place to ask this question. If not feel free to refer me elsewhere.

Some installation details:
- I have installed the python protobuf according to this guide:
https://github.com/protocolbuffers/protobuf/tree/main/python
- I have put the binary from protoc-21.8-osx-universal_binary.zip in /usr/local/bin and this path is at first place in the PATH variable
- the tests ran fine (Output: Ran 911 tests in 25.761s, OK (skipped=9))


Problem:
The generated _pb2.py file does not seem to be complete.
It contains:

_sym_db = _symbol_database.Default()

DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x19jfinder_duplicate.proto\x12\tjfinder\"\xef\x06\n\rduplicate_ads\x12\x10\n\x03\x63id\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x12\n\x05\x62q_id\x18\x14 \x01(\x05H\x01\x88\x01\x01\x12\x16\n\tj_title\x18\x02 \x01(\tH\x02\x88\x01\x01 ...................................x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'jfinder_duplicate_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_DUPLICATE_ADS._serialized_start=41
_DUPLICATE_ADS._serialized_end=920
_J_HASHES._serialized_start=922
_J_HASHES._serialized_end=1022


What seems to be missing:
_DUPLICATE_ADS = .... and _JOB_HASHES =.......
duplicate_ads = _reflection.GeneratedProtocolMessageType( .......
j_hashes = _reflection.GeneratedProtocolMessageType(.....

Consequence: Bigquery upload fails.

From what I know, the protoc files and _pb2.py generation using this installation have worked before, but I had to try a new installation due to the error:
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.

Do you have any suggestion on how I can solve this problem?

Many thanks in advance!

Nelson Meyer

unread,
Oct 28, 2022, 11:24:10 AM10/28/22
to Protocol Buffers
Just to let you know, that I solved the problem and it had nothing to do with the _pb2.py files.
Sorry for the "false alarm". Thanks!

Rodrigo Schramm

unread,
Jul 29, 2023, 5:26:57 AM7/29/23
to Protocol Buffers
Hi. I am having the same issue. How did you solve this?
Reply all
Reply to author
Forward
0 new messages