如何解决“AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"? [英] How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?
本文介绍了如何解决“AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 jupyter notebook 中执行 from object_detection.utils import label_map_util
时遇到了它.其实就是tensorflow对象检测教程notebook(自带tensorflow对象检测api)完整的错误日志:
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
~\AppData\Roaming\Python\Python37\site-packages\object_detection\utils\label_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
~\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,
22 serialized_pb=b'\n2object_detection/protos/string_int_label_map.proto\x12\x17object_detection.protos\"\xc0\x01\n\x15StringIntLabelMapItem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\x05\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12M\n\tkeypoints\x18\x04 \x03(\x0b\x32:.object_detection.protos.StringIntLabelMapItem.KeypointMap\x1a(\n\x0bKeypointMap\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05label\x18\x02 \x01(\t\"Q\n\x11StringIntLabelMap\x12<\n\x04item\x18\x01 \x03(\x0b\x32..object_detection.protos.StringIntLabelMapItem'
23 )
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
推荐答案
我通过 pip show protobuf
和 protoc --version
得到的 protoc 版本是不同的.pip 中的版本有点过时了.
The protoc version I got through pip show protobuf
and protoc --version
were different. The version in pip was a bit outdated.
在我用
pip install --upgrade protobuf
问题解决了.
这篇关于如何解决“AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文