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

前端 未结 4 1881
[愿得一人]
[愿得一人] 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:28

    The below three commands solved it for me:
    pip uninstall protobuf python3-protobuf
    pip install --upgrade pip
    pip install --upgrade protobuf
    Hope this helps.

    0 讨论(0)
  • 2020-12-15 03:35

    After trying many different solutions (i'm working on a Mac) the one that worked for me is to reinstall protobuf using:

    PROTOC_ZIP=protoc-3.7.1-osx-x86_64.zip
    curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/$PROTOC_ZIP
    sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
    sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
    rm -f $PROTOC_ZIP
    

    As is highlighted in this article

    0 讨论(0)
  • 2020-12-15 03:45

    This is a solution which worked for me I'm not sure if it'll work for others.

    The protoc verion I got through pip show protobuf and protoc --version were different. The version in pip was a bit outdated after I upgraded the pip version the problem was solved.

    In order to upgrade it use pip install --upgrade protobuf

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题