How to solve “AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key”?

前端 未结 4 1892
[愿得一人]
[愿得一人] 2020-12-15 02:49

I encountered it while executing from object_detection.utils import label_map_util in jupyter notebook. It is actually the tensorflow object detection tutorial

4条回答
  •  被撕碎了的回忆
    2020-12-15 03:45

    For others looking into this more recently newer google libraries are using proto plus, a wrapper for python proto messages. Using this helper function worked for me (cred: tobked)

    import json
    
    import proto
    
    def proto_message_to_dict(message: proto.Message) -> dict:
        """Helper method to parse protobuf message to dictionary."""
        return json.loads(message.__class__.to_json(message))
    

    https://github.com/googleapis/python-memcache/issues/19

提交回复
热议问题