ModuleNotFoundError: No module named 'tensorflow_core.estimator' for tensorflow 2.1.0

51.2k Views Asked by At

When using tensorflow, I have the following error messages

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.'

File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tensorflow_core.estimator'

The installed tensorflow related packages are shown as following. Do I need to update the estimator's version? If that's the case, how to install the estimator with right version?

enter image description here

8

There are 8 best solutions below

2
Marzi Heidari On

You need to either downgrade your tensorflow-estimator or upgrade tensorflow in order for the versions to match. You can do the downgrading using

pip install tensorflow-estimator==2.1.0
4
yudhiesh On

Try upgrading Tensorflow and Keras.

pip install tensorflow --upgrade
pip install keras --upgrade
2
willfliaw On

TL;DR: Just solved this issue by making sure that both tensorflow and tensorflow-estimator were in the same version. (in my case, I needed to downgrade tensorflow-estimator, so conda install tensorflow-estimator=2.1.0 solved it for me)

As you may have noticed, some tensorflow versions do not play well with certain GPUs, so I would first check some of the available builds with conda search tensorflow; then I would make sure that the chosen tensorflow build can actually recognize my GPU (with tf.config.list_physical_devices('GPU')); finally, I would search for a matching tensorflow-estimator build with conda search tensorflow-estimator and only then install it with conda install tensorflow-estimator=<chosen version> -n <my_venv>.

It should be noted, however, that all these steps are mostly useful if you have interest in using your GPU. If that is not the case, than upgrading both packages (or downgrading/upgrading them so their versions match) may be the way.

0
Pe Dro On

In my case, it was on Google Colab when I tried to import tensorflow. The problem was due to the version 1.14, got fixed by installing 1.15 rather.

0
eli44 On

Another one here: In my case I accidentially import tensorflow.keras as K , while I should've import keras as K apparently they differ and I got that same error message. Hope I can save someone some time.

0
Exarchias On

I wish to leave here a few parameters on how I solved the issue.

For an assignment that I had to work with Python 3.7.10, I tried to solve the issue by downgrading tensorflow_core.estimator to 2.1.0, (same as tensorflow), from its previous version, (2.6.0), but it didn't worked.

The combination that finally worked for me is, (for python 3.7.10):

  • tensorflow_core.estimator = 2.6.0
  • tensorflow = 2.3.0
  • tensorflow_base = 2.3.0
0
hljubic On

It is weird, but I had this problem because one string column wasn't converted to categorical variable.

0
nathan liang On

Just went through this headache—I referenced multiple pages/resources and tried a clean install of tensorflow on a new conda environment (Python 3.9.12, not 3.10.* because apparently the latter isn't yet fully compatible yet given how new it is as of this post) to test if my code would work, and, thankfully, it did.

What that basically confirmed was that my original conda environment's installation of tensorflow was somehow corrupted. My fix was to actually manually delete all folders starting with "tensor-" (tensor*) in my ~/anaconda3/envs/<my_env_name>/lib/python3.9/site-packages/ folder and then try a fresh install. Even though it was a cached install this time around, things still worked out.

To sum up, I would recommend deleting all tensorflow related packages and just doing a fresh install so that everything is correctly installed this time around.