How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?

The protoc version I got through pip show protobuf and protoc --version were different. The version in pip was a bit outdated.

After I upgraded the pip version with

pip install --upgrade protobuf

the problem was solved.


These three commands solved it for me:

pip uninstall protobuf python3-protobuf
pip install --upgrade pip
pip install --upgrade protobuf