PythNoob
PythNoob

Reputation: 143

Error on tensorflow cannot import name 'export_saved_model'

I keep getting this error when importing tensorflow as tf with the below error text:

ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model'

Code used is simply:

import tensorflow as tf

I have done:

  1. uninstalled and installed tensorflow through pip and condo via anaconda cmd prompt
  2. Restarted and cleared outputs from kernel, closing the jupyternotebook and restarting my computer

Code used for tensorflow unstallation:

  1. pip uninstall tensorflow or
  2. conda uninstall -y tensorflow

Code used for tensorflow installation:

  1. pip install tensorflow or
  2. conda install tensorflow

I can't seem to figure why it keeps saying:

"ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model'"

Upvotes: 10

Views: 26978

Answers (3)

MJimitater
MJimitater

Reputation: 939

The error went away when I restarted my jupyter notebook and restarted my kernel.

Upvotes: 0

Harisankar
Harisankar

Reputation: 1

I tried uninstalling several times but it didn't work. Finally i got the solution.

Uninstall tensorflow using pip and conda Uninstall Keras also

conda uninstall -y tensorflow
pip uninstall tensorflow
pip uninstall keras

Now open the anaconda prompt, install tensorflow again

conda create -n tf tensorflow
conda activate tf

I think the issue was due to library dependencies with older versions of tensorflow. Above procedure worked for me .

Upvotes: 0

hosh0425
hosh0425

Reputation: 98

Uninstalling and install again worked for me.

conda activate tf
pip uninstall -y tensorflow-gpu
pip install tensorflow-gpu

However, am still looking for the cause of this error. It was working just a few minutes ago but suddenly I have faced this error.

Upvotes: 2

Related Questions