When using the generated Python code from our protobuf classes, we get this error:
cannot import name descriptor_pb2
The equivalent C++ gen
I believe you have to generate descriptor_pb2.py
with protoc
yourself:
protoc descriptor.proto --python_out=gen/
gen/
is a folder with generated python classes.
After that, the following works just fine:
sys.path.append('../gen')
from descriptor_pb2 import FileDescriptorSet
../gen/descriptor_pb2.py
must exists.