已解决TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.1.0If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUPFERS_PYTHON_iMPLEMENTATION=python (but this will use pure-Python parsing and will be mch slower ,More information: https://developers. google.com/protocol-buffers/docs/news/2022-05-06#python-updates
(paddle) F: \pycharm\PyCharm Community Edition 2022.1.4\bin\PaddleOCR-release-2.6\PPOCRLabe1>-
文章目录
- 报错代码
- 报错翻译
- 报错原因
- 解决方法
- 帮忙解决
报错代码
粉丝群一个小伙伴想要安装一个PPOCRLabel,pip里已经把paddlepaddle和paddleorc下好了,然后输入PPOCRLabel --lang ch
,但是还是发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下:
报错信息内容如下:
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.1.0If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUPFERS_PYTHON_iMPLEMENTATION=python (but this will use pure-Python parsing and will be mch slower ,More information: https://developers. google.com/protocol-buffers/docs/news/2022-05-06#python-updates
(paddle) F: \pycharm\PyCharm Community Edition 2022.1.4\bin\PaddleOCR-release-2.6\PPOCRLabe1>-
报错翻译
报错信息翻译如下:
类型错误:无法直接创建描述符。
如果此调用来自_pb2.py文件,则生成的代码已过期,必须使用protoc>=3.1.0重新生成。如果无法立即重新生成protos,则其他一些可能的解决方法如下:
- 将protobuf包降级至3.20.x或更低。
- 设置PROTOCOL_BUPFERS_PYTHON_iMPLEMENTATION=PYTHON(但这将使用纯PYTHON解析,速度会慢很多,更多信息:https://developers.google.com/protocolbuffers/docs/news/2022-05-06#python更新(桨板)F:\pycharm\pycharm社区版2022.1.4\bin\PidleOCR-release-2.6\PPOCRabe1>
报错原因
报错原因:
仔细阅读报错信息就会发现,报错的主要原因是因为protobuf的版本太高而导致编译错误,所以我们只需要按照编译器提示的信息下载3.19.0对应的版本即可解决问题。小伙伴按下面的代码安装指定版本即可!!!
解决方法
执行下面的pip安装命令即可:
pip install protobuf==3.19.0
或者:
pip install 'protobuf~=3.19.0'
帮忙解决
本文已收录于:《告别Bug》专栏
本专栏用于记录学习和工作中遇到的各种疑难Bug问题,以及粉丝群里小伙伴提出的各种问题,文章形式:报错代码 + 报错翻译 + 报错原因 + 解决方法,包括程序安装、运行程序过程中等等问题,订阅专栏+关注博主后如遇到其他问题可私聊帮忙解决!!!