. Advertisement .
..3..
. Advertisement .
..4..
Python is one general-purpose programming language with powerful high-level data structures and a large library system. It is completely dynamically typed and uses automatic memory allocation. Moreover, its syntax is clear and simple.
You receive the following notification while performing your task: “AttributeError: module ‘google.protobuf.descriptor’ has no attribute’_internal_create_key'”
This was one of the most common blunders that a programmer could make. As a result, does it occur, and if so, is it reversible? Let us work together to determine the most effective techniques.
How Does It Occur?
The program shows an error message when you are importing label_map_util in jupyter notebook:
~\AppData\Roaming\Python\Python37\site-packages\object_detection\protos\string_int_label_map_pb2.py in <module>
19 syntax='proto2',
20 serialized_options=None,
---> 21 create_key=_descriptor._internal_create_key,
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
How to handle the error “AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key'”
Surprisingly, you were able to repair it by utilizing some of the strategies listed below.
Tip 1: Upgrade pip
Firt of all, you need to uninstall current protobuf version:
pip uninstall protobuf python3-protobuf
Then upgrade pip:
pip install --upgrade pip
After that, upgrade protobuf again:
pip install --upgrade protobuf
Tip 2: Upgrade protobuf version
The cause of the error may be that the version you are using is old. Try updating them with the following:
pip install --upgrade protobuf
For python3, try:
pip3 install --upgrade protobuf
Tip 3: Use this script
For those interested in this, newer Google libraries use proto plus, a wrapper for Python proto messages. This helper function worked well for me.
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))
Tip 4: Install with conda
Firsly, you should install “conda install protobuf” then using the following command:
conda install -c conda-forge streamlit
Conclusion
If you’re perplexed by the error “AttributeError: module ‘google.protobuf.descriptor’ has no attribute’_internal_create_key'” the solutions presented here are the most effective.
Even if you still need assistance or have fundamental Python questions, there is a large community to which you can turn, and everyone is usually eager to assist. Finally, we wish all of our readers a fantastic day full of new ideas.
Leave a comment