一开始遇到这个问题以为只要安装google库就行了,于是执行以下命令

pip install google

安装完成以后仍然报错,然后发现需要安装protobuf库

pip install protobuf

安装完成以后发现还是不行又报错了,报错信息如下

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.19.0.
If 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_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower)

原来是版本太高了,需要安装更低版本,执行命令

pip install protobuf==3.19.0

ok,这下可以用了

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐