在pycharm报出这个错误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 poss
时间: 2023-07-20 14:07:13 浏览: 155
ible causes of this error include:
1. Trying to create a descriptor object directly, instead of using a factory function or constructor.
2. Passing incorrect arguments to the factory function or constructor.
3. Using an outdated version of the protobuf library.
To resolve this issue, you can try the following steps:
1. Make sure that you are using the latest version of the protobuf library. You can upgrade to the latest version using pip:
```
pip install --upgrade protobuf
```
2. If you are still encountering the same error, try regenerating your protobuf code using a newer version of protoc:
```
protoc --version
```
If your version of protoc is older than 3.19.0, you will need to update it. You can download the latest version from the official protobuf website: https://developers.google.com/protocol-buffers
3. If neither of the above steps work, check your code for any instances where you are directly creating descriptor objects. Instead, use the appropriate factory function or constructor to create descriptor objects.
阅读全文