keras plot_model tells me to install pydot

随声附和 提交于 2019-11-27 07:51:12

问题


I'm using python 3.6.3 on a windows 10 machine. I installed pydot and graphviz using pip install via:

    py -m pip install pydot
    py -m pip install graphviz

I also went to the graphviz website and downloaded and installed the windows version here: http://www.graphviz.org/Download_windows.php which default installed to program files(x86). But when I go to plot my model in keras, I still get the error saying I have to install pydot and graphviz and that the import failed. I can do

    import pydot
    import graphviz

on my python console just fine, they throw no errors. What else should I do to be able to graph my neural net?


回答1:


The path(s) to the installed GraphViz executables (dot, neato, etc.) need to be in the PATH environment variable, in order for pydot to find them. pydot used to search for those executables in earlier versions, but not any more.

Also:

  1. pydot is a Python package.
  2. GraphViz is a collection of tools written in C for computing graph layouts
  3. graphviz is a Python package entirely unrelated to pydot. These two Python packages do not interact in any way with each other. Installing one of them should suffice (together with GraphViz).

See also:

  • https://github.com/erocarrera/pydot/issues/126
  • https://github.com/erocarrera/pydot/commit/812e3c40dac1e0225391481073c64da5bafba93e#commitcomment-18236709
  • https://github.com/erocarrera/pydot/commit/812e3c40dac1e0225391481073c64da5bafba93e#commitcomment-18222580

and links from there.




回答2:


Just to complete the @dataLeo 's solution, Python 3 users can use pydotplus package instead of pydot-ng package. To summarize:

  1. install pydot+graphviz and pydotplus by commands "conda install pydot" and "conda install -c conda-forge pydotplus".
  2. Go to the vis_utils.py file and change line 11 from import pydot to import pydotplus as pydot.

PS: You can locate the vis_utils.py file by checking help for plot_model command in ipython console, i.e. after from keras.utils import plot_model, type ??plot_model in ipython console.

Tested on Windows 10-64 bit with Anaconda python-3.6




回答3:


Complementing @Ioannis answer, you have to install GraphViz executables via conda (conda install GraphViz).

For my case, after installing GraphViz I tried with the latest pydot (pip install pydot) and the error was resolved.



来源:https://stackoverflow.com/questions/47188756/keras-plot-model-tells-me-to-install-pydot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!