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

Dung Do Tien May 30 2021 315

I have seen a 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')

But it showed an error : 

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

Please tell me how can I resolve this issue?

Have 2 answer(s) found.
  • S

    Suthep Sangvirotjanaphat May 30 2021

    You need to install two packages pydotplusgraphviz

    conda install pydotplus
    conda install graphviz 

    And import them:

    import pydotplus
    from keras.utils import plot_model
    keras.utils.vis_utils.pydot = pydotplus
    plot_model(your_model_name, to_file='model.png', show_shapes=True)

    It's resolved this issue for me.

  • Đ

    Đàm Ngọc Sơn May 30 2021

    You need to install some packages below. The following commands solved the problem for me:

    Step 1: pip install pydot

    Step 2: pip install pydotplus

    Step 3: sudo apt-get install graphviz

    I hope it works for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close