ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work

bit_scientist picture bit_scientist · Dec 2, 2017 · Viewed 25.4k times · Source

I have seen similar issue but it is not solved either, so I decided to ask.

I am trying to visualize my model in keras using

from keras.utils import plot_model
plot_model(model, to_file='model.png')

First, it showed error

ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

Accordingly, I installed pydot and graphviz through Anaconda prompt activating my environment using

conda install -c https://conda.binstar.org/t/TOKEN/j14r pydot
conda install -c https://conda.binstar.org/t/TOKEN/j14r graphviz

Then, I closed spyder and reopened it. When I run code snippet, it is still showing the same error. What am I missing?

Answer

iun1x picture iun1x · Apr 3, 2019

The following commands solved the problem for me

  1. pip install pydot
  2. pip install pydotplus
  3. sudo apt-get install graphviz