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?
PyDotPlus is an improved version of the old pydot project that provides a Python Interface to Graphviz's Dot language. Differences with pydot: Compatible with PyParsing 2.0+. Python 2.7 - Python 3 compatible.
Pydot is a Python library, also written in Python, that "serves as a graphical interface to Graphviz, an open source graph visualization software. GraphViz is written in DOT language, but Pydot provides the ability to parse and dump data, between Python and DOT."[
The following commands solved the problem for me
It seems like you are using Windows. In that case, see this SO Q&A stream and/or this Keras issue on gitub.
Following hints from both sources, it seemed likely there was an install error and/or a path error. I used pip uninstall
on all related packages, then:
pip install pydot
pip install pydotplus
pip install graphviz
Then:
I was running a python script myscript.py
within a Windows cmd
window. I had to close and reopen that to refresh the PATH, but then plot_model()
produced output fine.
Solution found from: https://github.com/XifengGuo/CapsNet-Keras/issues/69#issuecomment-483273641
I followed the advice of uninstalling and reinstalling pydot + pydotplus and that successfully solved the issue on my Windows 10 machine using Anaconda 3.
conda uninstall pydot
conda uninstall pydotplus
conda uninstall graphviz
then
conda install pydot
conda install pydotplus
Note: installing pydot also installed graphviz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With