Keras: "RuntimeError: Failed to import pydot." after installing graphviz and pydot Keras: "RuntimeError: Failed to import pydot." after installing graphviz and pydot python python

Keras: "RuntimeError: Failed to import pydot." after installing graphviz and pydot


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 graphvizconda 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 kerasimport pydotplusfrom keras.utils.vis_utils import model_to_dotkeras.utils.vis_utils.pydot = pydotplot_model(your_model_name, to_file='model.png')

That's worked for me.On mac Anaconda python=3.6.8