Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
836 views
in Technique[技术] by (71.8m points)

python - How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?

I encountered it while executing from object_detection.utils import label_map_util in jupyter notebook. It is actually the tensorflow object detection tutorial notebook(it comes with the tensorflow object detection api) The complete error log:

AttributeError                            Traceback (most recent call last)
<ipython-input-7-7035655b948a> in <module>
      1 from object_detection.utils import ops as utils_ops
----> 2 from object_detection.utils import label_map_util
      3 from object_detection.utils import visualization_utils as vis_util

~AppDataRoamingPythonPython37site-packagesobject_detectionutilslabel_map_util.py in <module>
     25 import tensorflow as tf
     26 from google.protobuf import text_format
---> 27 from object_detection.protos import string_int_label_map_pb2
     28 
     29 

~AppDataRoamingPythonPython37site-packagesobject_detectionprotosstring_int_label_map_pb2.py in <module>
     19   syntax='proto2',
     20   serialized_options=None,
---> 21   create_key=_descriptor._internal_create_key,
     22   serialized_pb=b'
2object_detection/protos/string_int_label_map.protox12x17object_detection.protos"xc0x01
x15StringIntLabelMapItemx12x0c
x04namex18x01 x01(x12

x02idx18x02 x01(x05x12x14
x0cx64isplay_namex18x03 x01(x12M
keypointsx18x04 x03(x0bx32:.object_detection.protos.StringIntLabelMapItem.KeypointMapx1a(
x0bKeypointMapx12

x02idx18x01 x01(x05x12
x05labelx18x02 x01("Q
x11StringIntLabelMapx12<
x04itemx18x01 x03(x0bx32..object_detection.protos.StringIntLabelMapItem'
     23 )

AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The protoc version 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 with

pip install --upgrade protobuf

the problem was solved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...