I have a Python module that imports a Protobuf class. When I try to run the module or the tests for that module, I get fhe following error:
_ ERROR collecting tests/test_load_protobuf_data.py _tests/test_load_protobuf_data:7: in <module> from src.protobuf_classes import testdata_pb2 as Testdatasrc.protobuf_classes/testdata_pb2.py:17: in <module> DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(E TypeError: Couldn't build proto file into descriptor pool: Depends on file 'google/protobuf/timestamp.proto', but it has not been loaded
I expected the module to import all dependencies successfully and pytest to load the module and run the tests successfully.
I'm using a virtual environment for that project, but the timestamp.proto
is not part of the protobuf library. Instead, the .proto files are stored under /usr/include/google/protobuf/
.
I tried to copy the file to my project folder under google/protobuf/timestamp.proto
, but this didn't solve the problem. I need a way to tell python/protobuf where to look for the proto files.