paddlepaddle安装问题protobuf package to 3.20.x or lower.

按照官方文档安装paddlepaddle 2.3.0后,进行环境验证时,总是提示如下错误:

TypeError: Descriptors cannot not be created directly.
If this call came from a 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).

这说明我们使用的protobuf库的版本高了,可以卸载已经安装过的protobuf 版本,再安装3.20.x以下的版本,我们可以使用3.19.0版本即可,命令如下:

1、卸载protobuf 已经安装的版本

pip uninstall protobuf

Found existing installation: protobuf 4.21.1
Uninstalling protobuf-4.21.1:
  Would remove:
Proceed (Y/n)? y
  Successfully uninstalled protobuf-4.21.1


pip install protobuf==3.19.0

Installing collected packages: protobuf
Successfully installed protobuf-3.19.0


>>> import paddle
>>> paddle.utils.run_check()

Running verify PaddlePaddle program …
PaddlePaddle works well on 1 CPU.
W0601 23:27:12.940966 28720] Find all_reduce operators: 2. To make the speed faster, some all_reduce ops are fused during training, after fusion, the number of all_reduce ops is 2.
PaddlePaddle works well on 2 CPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.


物联沃-IOTWORD物联网 » paddlepaddle安装问题protobuf package to 3.20.x or lower.