I was trying to use the TensorFlow but unluckily I am facing the below 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. 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).
Let’s get started with this article, where we’ll learn about all of the possible solutions to fix the TypeError: Descriptors cannot not be created directly Error.
What TypeError: Descriptors cannot not be created directly Error Mean?
The latest version of Protobuf was recently released, and as a result of this update, this problem occurs.
How To Fix TypeError: Descriptors cannot not be created Error?
Let’s discuss below all possible ways to fix the TypeError: Descriptors cannot not be created directly Error:
Fix 1: Downgrade protobuf to 3.20.1 Version
The latest version of protobuf was recently released, and as a result of this update, this problem occurs. All we have to do now is downgrade protobuf to version 3.20.1, and the problem will be resolved. Simply run following below command in your terminal to downgrade protobuf:
pip install --upgrade "protobuf<=3.20.1"
Fix 2: Update TensorFlow version to the Most Recent Version
On the 23rd of May 2022, TensorFlow released version 2.9.1. Simply update to the most recent version, and your issue should be resolved. Use the below command to upgrade the TensorFlow version to latest release:
pip install tensorflow==2.9.1
Conclusion
TypeError: Descriptors cannot not be created directly Error basically occured because of latest version upgrade of Protobuf that was recently released, and as a result of this update, this problem occurs.
To fix the issue, either Downgrade protobuf to 3.20.1 Version using command “pip install –upgrade “protobuf <=3.20.1” OR Update TensorFlow version to the Most Recent Version using command “pip install tensorflow==2.9.1”.
Read More:
Steam Summer Sale is Live now! To Check the Steam Summer Sale Clues Answers, Click Below:
- Steam Summer Sale Clue 1 Answer
- Steam Summer Sale Clue 2 Answer
- Steam Summer Sale Clue 3 Answer
- Steam Summer Sale Clue 4 Answer
- Steam Summer Sale Clue 5 Answer
- Steam Summer Sale Clue 6 Answer
- Steam Summer Sale Clue 7 Answer
- Steam Summer Sale Clue 8 Answer
- Steam Summer Sale Clue 9 Answer
- Steam Summer Sale Clue 10 Answer