How to Fix AttributeError: module ‘tensorflow’ has no attribute ‘ConfigProto’

Diagram of module tensorflow has no attribute ConfigProto


AttributeError: module tensorflow has no attribute ConfigProto error occurs in Python because, with the advent of TensorFlow 2.x, ConfigProto was removed from the TensorFlow module. 

What is ConfigProto?

ConfigProto is a configuration protocol used in TensorFlow 1.x versions. It handled session configuration, such as limiting resource use and facilitating logging.

Changes from TensorFlow 1.x to 2.x

TensorFlow 2.x brought many changes. The most significant was the shift to Eager execution, making TensorFlow more intuitive and user-friendly. However, some changes, like removing ConfigProto, can cause confusion and errors for those used to TensorFlow 1.x.

How TensorFlow 2.x handles configurations

In TensorFlow 2.x, the ConfigProto function’s features are integrated into other parts of the module, eliminating the need for ConfigProto.

How to Fix it?

Solution 1: Using tf.compat.v1

If your existing code uses ConfigProto, you can use the compatibility module tf.compat.v1 to avoid errors. It allows you to run TensorFlow 1.x code in TensorFlow 2.x.

Solution 2: Other methods to manage session configuration

Instead of ConfigProto, you can use other methods like tf.config.experimental to manage resource consumption and other settings in TensorFlow 2.x.

Best Practices when Updating TensorFlow

Upgrade your TensorFlow library to the latest version. You can do this by running the following command in your terminal:

pip install --upgrade tensorflow

If you are using Anaconda, you can run the following command:

conda update tensorflow

Community resources and TensorFlow updates

Follow the TensorFlow community on GitHub, StackOverflow, and other forums. They often provide useful information about updates and solutions to common issues.


It’s common to run into AttributeErrors like ‘module tensorflow has no attribute ConfigProto’ when transitioning from TensorFlow 1.x to 2.x. However, understanding the changes and knowing how to adapt to them makes the process smoother.

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.