Solving Tensorflow AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key”

Tensorflow AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key” is a popular error which occurs with protobuf.

In today’s article I am going to deal with a confusing error and explain why it takes place and how to fix it, with a set of possible solutions.

Exploring the Tensorflow AttributeError: module ‘google.protobuf.descriptor’ has no attribute ‘_internal_create_key”

This is a popular error which occurs with protobuf.

Bellow is the error message, please make sure it is the right one.

                                                                       #
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
                                                                       #

I hope one of the solutions bellow will help you solve the problem and get rid of the error for good.

Solution 1 : Correctly upgrade pip and protobuf

The first method is a step by step fix.

First, we should uninstall python3-protobuf and protobuf using the command bellow.

                                                                       #
pip uninstall protobuf python3-protobuf
                                                                       #

Then we should upgrade pip like in the following command

                                                                       #
pip install --upgrade pip
                                                                       #

Finally, we should upgrade protobuf using the command bellow

                                                                       #
pip install --upgrade protobuf
                                                                       #

This method should work for most people, but if that does not work, try the next method instead.

Solution 2 : Another way to upgrade pip and protobuf

The second solution is also a step by step solution.

First, we should start by upgrading pip using the command bellow

                                                                       #
pip install --upgrade pip
                                                                       #

The second step is to upgrade protobuf using this command

                                                                       #
pip install --upgrade protobuf
                                                                       #

Or use pip3 to upgrade it if you have python3

                                                                       #
pip3 install --upgrade protobuf
                                                                       #

I hope the methods above have been helpful, I hope you solved the error already.

Summing-up : 

I hope this article has helped you achieve your objective, If you like the effort we did here, please consider donating to our Kofi account located at the top of this page.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/