Skip to content Skip to sidebar Skip to footer

Keras: "runtimeerror: Failed To Import Pydot." After Installing Graphviz And Pydot

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

Solution 1:

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.

Solution 2:

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.

Solution 3:

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

Solution 4:

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.

Solution 5:

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.

Post a Comment for "Keras: "runtimeerror: Failed To Import Pydot." After Installing Graphviz And Pydot"