AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key’ error typically occurs when you are using an outdated version of the “protobuf” package. It can occur when there is a version mismatch between the “protobuf” and “protoc” libraries.
How to fix it?
To fix the AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key’ error, “upgrade the protobuf” package using this command:
pip install --upgrade protobuf
If you’re using TensorFlow, you may want to check the specific version of protobuf required for your version of TensorFlow. This information can usually be found in the TensorFlow release notes or documentation.
If you are facing the error, then you can use the below command step-by-step:
Step 1: You can uninstall the current version of protobuf with the following command
pip uninstall protobuf
Step 2: Install the Required protobuf Version
Once you’ve found the required version, install it using pip. For example, if the required version is 3.9.2, you can install it with:
pip install protobuf==3.9.2
Step 3: Verify the Installation
import google.protobuf print(google.protobuf.__version__)
I hope, just like me, you will have the latest version of the “protobuf” module and fix the error!