Running on MacOS, Catalina.
Other Details:
Jupyter Notebook
!pip install --no-deps keras==2.2.4
!pip install --no-deps tensorflow==1.15.3
Python Version 3.7
Following virtually step-by-step from: https://machinelearningmastery.com/how-to-train-an-object-detection-model-with-keras/
Anyone encounter this error / know how to resolve?
Resolved by restarting Jupyter Notebook kernel. Consulted various resources online to install / uninstall packages and items, so difficult to pinpoint was produced the desired result -- but for those encountering this, ensure to restart kernel.
On Windows, in my Anaconda virtual environment running Python 3.7, I have fixed this issue by simply upgrading TensorFlow and Keras to the latest versions.
I did this by running the following PIP command in my Anaconda terminal:
pip install tensorflow --user --upgrade
pip install keras --user --upgrade
I get this error when I try to import Keras into my project.
How to solve ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
I verified the versions I have installed (with pip) for everything and I have:
Python 3.7.7
Tensorflow 2.2.0
keras 2.4.3
I have linked a picture of the full error. There is some stuff about Dll but I'm not sure if this is what creates the error.
Tensorflow requires Python 3.5–3.8 , pip and venv >= 19.0
in order to fix it:
sudo apt install python3-pip
pip3 install --upgrade pip
python3 -m pip install tensorflow
if you already had tensorflow installed substitute the last command this this:
pip3 install --upgrade tensorflow
hope it helped.
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
Fix:
python -m pip install –upgrade pip
pip install keras==2.1.5
This worked for me.
If above step are not solving the error then check your libraries with specific version.
Python==3.6.4
Numpy==1.18.5
Pandas==1.1.4
scikit-learn==0.21.2
Tensorflow==1.13.1
keras==2.1.5
Hope this worked for you.
Please update keras version.
python -m pip install –upgrade pip
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:
uninstalled and installed tensorflow through pip and condo via anaconda cmd prompt
Restarted and cleared outputs from kernel, closing the jupyternotebook and restarting my computer
Code used for tensorflow unstallation:
pip uninstall tensorflow
or
conda uninstall -y tensorflow
Code used for tensorflow installation:
pip install tensorflow
or
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'"
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.
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 .
The error went away when I restarted my jupyter notebook and restarted my kernel.
I installed latest tensorflow version as:
sudo pip2 install tensorflow
But while import layers as
from tensorflow.contrib import layers
I get an error:
cannot import name bayesflow
What am I missing?
I am using Ubuntu 14.
Was in the similar position as you: tf.contrib.data.TFRecordDataset(filenames) was generating the same error. After a lot of searching and trying I found that I should update dask. So
pip install --upgrade dask
solved the problem for me.
For those who still experience this problem, the best is to upgrade tensorflow with sudo pip install --upgrade tensorflow or even uninstall it sudo pip uninstall tensorflow and reinstall it sudo pip install tensorflow.
When it's done you have to close the ipython or any shell you are using (this is important)
I'm using Anaconda Python 2.7 on windows 10
I was planning on doing Keras visualization so (whilst spyder was open) I opened the Anaconda command prompt and pip installed graphviz and pydot. Now when I try run the following:
from keras.models import Sequential
or any sort of "from keras." , I get the error:
ImportError: cannot import name gof
I have uninstalled and reinstalled Keras, Graphviz and pydot. i am using the development version of theano. I cannot find a fix.
P.S
If I uninstall graphviz and pydot, keras works again
EDIT
After uninstalling anaconda and reinstalling it including theano, keras, graphviz and pydot I now get the following error:
from keras.utils.visualize_util import plot
Using Theano backend.
Using gpu device 0: GeForce GTX 970M (CNMeM is disabled, cuDNN not available)
Traceback (most recent call last):
File "<ipython-input-1-65016ddab3cd>", line 1, in <module>
from keras.utils.visualize_util import plot
File "C:\Anaconda2\lib\site-packages\keras\utils\visualize_util.py", line 8, in <module>
raise RuntimeError('Failed to import pydot. You must install pydot'
RuntimeError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
I used pip install graphviz and pip install git+https://github.com/nlhepler/pydot.git
The error message is a bit misleading, as you can see here. The problem is that graphviz is not installed.
But you mention that graphviz was installed using pip. This is also misleading, since that graphviz package is just a python wrapper, and the graphviz binaries have to be installed separately for the python wrapper to work.
If you are using an Anaconda environment, you'd better install pydotplus and graphviz via conda install.
conda install graphviz
conda install pydotplus
Note:
You'd better update your Keras to the newest version (2.0.9+), it can automatically check and choose which one of pydotplus,pydot-ng,pydot to be used. pydot-ng has been unmaintained for a long time, and it only supports py3.4- and py2.7.
What I did is followed.
import keras
import pydotplus
from keras.utils.vis_utils import model_to_dot
keras.utils.vis_utils.pydot = pydot
plot_model(your_model_name, to_file='model.png')
That's worked for me.
On mac Anaconda python=3.6.8
Keras 2.0.6 looks for pydot-ng (better maintained) and then if it's not found, falls back on pydot. I resolved this issue by installing pydot-ng from source.
I had the same problem. I am using Anaconda python on Ubuntu. but it seems that Keras uses system's python not the Anaconda python. Initially, I installed pydot and graphviz using conda. When I installed pydot and graphviz in system's python(using /usr/bin/pip install pydot) it worked fine.
Install graphviz by brew in osx brew install graphviz, for ubuntu use apt-get install graphviz, do not need to install graphviz by pip.
I had similar problem with my Keras (without anaconda). I have solved my problem using this way
sudo pip install pydot
sudo pip install graphviz
sudo add-apt-repository ppa:gviz-adm/graphviz-dev
sudo apt-get update
sudo apt-get install graphviz-dev
1)Conda install graphviz
2)pip install graphviz
3)pip install pydot
then:
import os
os.environ["PATH"] += os.pathsep + AppData\\Local\\Continuum\\anaconda3\\envs\\tensorflow\\Library\\bin\\graphviz'
For Anaconda on Mac:
To install this package with conda run:
conda install -c anaconda graphviz
Install graphviz to the system. Download the package from here, or on Mac:
brew install graphviz
Install python pydot-ng and graphviz wrapper.
pip install pydot-ng graphviz
conda install -c anaconda pydot-ng #Anaconda user
Use pydot-ng in your code
import pydot_ng as pydot
If Keras visualization utils still uses pydot, try to change import pydot to import pydot_ng as pydot in visualize_util.py
The below works inside a jupyter notebook runing in a jupyter/tensorflow-notebook docker container.
!conda install -y graphviz pydotplus
import pydotplus
import keras.utils
keras.utils.vis_utils.pydot = pydotplus
keras.utils.plot_model(your_model_name, to_file='model.png', show_shapes=True)
You need to tell keras to use pydotplus
it is nothing related to pydot or graphviz if you have installed via pip.
You should go download graphviz brinary and install.
Don't forget adding the bin folder into your PATH: C:/Program Files (x86)/Graphviz2.38/bin/
And after that to close and reopen your console.
After installing pydot and graphviz and adding graphviz to the path, you can restart the IDE or terminal. see here.