1
votes

I'm using python 3.8.2 , keras 2.3.1 and tensorflow 2.2.0rc4 . just with the following code :

import keras
from keras.models import sequential

I have this error : AttributeError: partially initialized module 'keras.backend' has no attribute 'eager' (most likely due to a circular import)

if I use :

import tensorflow

or

from tensorflow.keras import ....

new error :

AttributeError: partially initialized module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function' (most likely due to a circular import)

full traceback: enter image description here

enter image description here

2
Could you try replacing keras with tensorflow.keras and see if the error is still there? - Raj Srujan Jalem
Please include the full traceback in your question. - Dr. Snoopy
I have new error with tensorflow.keras ,,, @RajSrujanJalem - Tarek Rida Jurdi

2 Answers

2
votes

My suggestion is to reinstall the package. Sometimes this happens due to the installation problem.

Use the following code to do so

Uninstall tensorflow

pip uninstall tensorflow

Requires the latest pip

pip install --upgrade pip

To install keras as separate package

pip install Keras

Current stable release for CPU and GPU

pip install tensorflow

Try this and hope this helps you.

0
votes

It's an install problem, most likely; K.eager was introduced in Keras 2.3.0 (and is included in Keras 2.3.1), so your Python interpreter is somehow reading code of 2.2.5 or earlier.

A possible culprit is an Anaconda mishap. First run conda uninstall keras. Then, in the anaconda3 directory, search "keras" and delete all results. Lastly, run conda install -c conda-forge keras, which should download version 2.3.1. You might need to run similar steps with TensorFlow (in fact, it's better you do, and first reinstall TensorFlow then Keras).

P.S., your code is probably from keras import Sequential, as sequential should error differently.