关于Descriptors cannot not be created directly报错

报错信息为:

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:

Downgrade the protobuf package to 3.20.x or lower.
Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Process finished with exit code 1

解决方法:

打开Anaconda Prompt终端,进入当前使用的pytroch环境
分别执行以下两个命令

pip uninstall protobuf
pip install protobuf==3.19.0

你可能感兴趣的:(pytroch,深度学习,pytorch,python,pycharm)