Attributeerror: module ‘tensorflow’ has no attribute ‘configproto’

In this article, we will discuss the solutions for attributeerror: module ‘tensorflow’ has no attribute ‘configproto’ that you are currently facing. This attribute error has various ways to fix it.

If this is your first time encountering this error, we understand that it’s quite hard to resolve it right away. Especially if you are a beginner in Python programming.

Fortunately, this article will give you a thorough explanation of what this error means and how you can fix it. We’ll guide you through the whole process to fix the attributeerror module tensorflow has no attribute configproto.

What is “attributeerror: module ‘tensorflow’ has no attribute ‘configproto'” error?

AttributeError: module 'tensorflow' has no attribute 'ConfigProto'

The attributeerror: module tensorflow’ has no attribute configproto is a common error that is usually encountered by TensorFlow users. This error message indicates that the ConfigProto attribute is unable to locate from the TensorFlow module.

In addition to that, this attribute is used to specify the configuration of the TensorFlow session.

Why does this error “attributeerror: module ‘tensorflow’ has no attribute ‘configproto'” occur?

This error occurs because configproto is completely deprecated in TensorFlow 2.0. In version 2 of Tensorflow, it does not support or the configproto module is not compatible with Tensorflow 2.0.

How to fix “attributeerror: module ‘tensorflow’ has no attribute ‘configproto'”

The following are effective solutions that you may use to fix the attribute error:

1. Use Tensorflow version 1 syntax

import tensorflow as tf

config = tf.ConfigProto

If you are using the program above it will throw an error. Try to replace it by the following code:

1. Copy the import statement.

import tensorflow as tf

2. Then, you have to replace the tf.ConfigProto by tf.compat.v1.ConfigProto

import tensorflow as tf
config = tf.compat.v1.ConfigProto()
sess = tf.compat.v1.Session(config=config)

3. Additionally, if you don’t like to touch your code, you just have to add these 2 lines in the file w/ Tensorflow code:

import tensorflow.compat.v1 as tf

2. Downgrade Tensorflow version

When the solution above does not resolve the issue you can try to downgrade the version of Tensorflow you are using into version 1. However, this is not commended to use due to, it might break some Python script that is not compatible with the version 1 of Tensorflow.

Hence, if you are sure that you are just using the 1.x code base and only the installation version, you can use that command to downgrade the Tensorflow.

You can easily downgrade the tensorflow version to 1. x using the following command:

pip install tensorflow==1.15.5

3. Complete the program code conversion from 1. x to 2. x

If you already installed the TensorFlow 2.0 x in your system and wanted to use TensorFlow version 1.x as well as the supporting code. Therefore, use the following syntax if you encounter this attribute problem.

tf_upgrade_v2 \
  --intree code/ \
  --outtree code_v2/ \
  --reportfile text.txt

Related Articles for Python Errors


This article provides solutions for the attributeerror: module ‘tensorflow’ has no attribute ‘configproto’which is a big help in solving the problem you are currently facing.

Thank you very much for reading to the end of this article. Just in case you have more questions or inquiries, feel free to comment, and you can also visit our website for additional information.

Leave a Comment