Skip to content Skip to sidebar Skip to footer

Attributeerror: Partially Initialized Module 'tensorflow' Has No Attribute 'config' (most Likely Due To A Circular Import)

I keep on receiving this error: Traceback (most recent call last) File 'tensorflow.py', line 1, in import tensorflow as tf File 'C:\Users\Anush\Desktop\tensorf

Solution 1:

In my case, I just rename my current script name from code.py to testing.py. Then it works perfectly.

Suspected same code.py file name is inside the import tensorflow libraries causing this circular import error.

Solution 2:

When python executes a script, it includes the script's directory in the python path. This makes it easy for programmers to supply their own modules for the script without an explicit install. Also, python doesn't treat that top level script as a module (or more precisely, it names it __main__).

In your case, you named your script "tensorflow.py". Python executes the script and when it sees import tensorflow, it imports your module, not the real tensorflow package. Since it doesn't have a module named tensorflow yet (the original is __main__), it executes the file again and sees that import tensorflow a second time, but again, its still your same tensorflow.py. That could go on forever, but python detect the circular import and emits the error you see.

Its too bad that python does this. It makes it easier to deploy modules and packages but its kind of fragile. You have to make sure that your .py file names don't clash with anything that may show up in your python installation.

The solution is to rename C:\Users\Anush\Desktop\tensorflow.py. And just don't name it the same as any python package you may install.

Solution 3:

Maybe anaconda prompt

conda install tensorflow

Post a Comment for "Attributeerror: Partially Initialized Module 'tensorflow' Has No Attribute 'config' (most Likely Due To A Circular Import)"