Why do I see “cannot import name descriptor_pb2” error when using Google Protocol Buffers?

前端 未结 5 600
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 03:51

When using the generated Python code from our protobuf classes, we get this error:

cannot import name descriptor_pb2

The equivalent C++ gen

5条回答
  •  清酒与你
    2021-01-18 03:59

    In my case, not finding descriptor_pb2 occurred because protobuf wasn't correctly installed. In the python subdirectory of protobuf, be sure to run

    python setup.py build
    python setup.py test
    python setup.py install (as root)
    

提交回复
热议问题