. Advertisement .
..3..
. Advertisement .
..4..
Are you struggling to find the answer for the problem “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 are unsure about the method, the post below is what you’re looking for. Take a moment and let’s read our article and you will solve it as well as the relevant expertise in no time.
What causes error “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.”?
The main cause of the above error is that your current version is no longer compatible, or the function is now not supported in the new version. The developer soon released a new upgraded version of Protobuf, also because of this update, some users encountered the incompatibility error “TypeError: Descriptors cannot 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.
”
How to fix it?
Fortunately, these errors are also quite easy to fix. Here are some solutions for you. Each method has different pros and cons. Please consider and choose the method that is most suitable and fastest for you.
Solution 1: Update to the latest version
First of all, we will introduce you to the most commonly used method. If the cause of the error is mainly an incompatibility with the current version, your best solution is to update your TensorFlow version to the latest version or higher than your current version.
As of 2022, the developer has released the latest version, TensorFlow 2.9.1. To install the package, run the following command:
pip install tensorflow==2.9.1
Solution 2: Set more environment variables
Another way to handle this is that you can add environment variables to your specific program. Add the following command line:
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
However, when choosing this option, you also need to consider it because it can cause the machine to run slowly.
Solution 3: Downgrade the protobuf version
With this approach, our approach will be to downgrade the protobuf version from 4.21.2 to 3.20.1. Operate as follows:
- Step 1: Access your project in settings
- Step 2: Select Python Interpreter
- Step 3: Install version 3.20.1 using command line
pip install --upgrade "protobuf<=3.20.1
”
So your error is solved.
Conclusion
To summarize, ITtutoria has introduced to you three commonly used methods to handle the error “TypeError: Descriptors cannot 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 encounter any difficulties during the operation, please leave a comment in the chat box below so we can support you as soon as possible.
Leave a comment