Tag Archives: pydot

Attribute


An error occurred when Python called the pydot.py file

AttributeError: module ‘OS’ has no attribute ‘errno’

why
No longer available in Python 3.7os. errno
Change the method
Change python3.7/ site-packages /pydot.py to import errno. Line 1863:

if e.errno == errno.ENOENT:
Note: If NameError: Name ‘errno’ is not defined, add import errno to pydot.py

[Keras] ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to

problem description

what happened was, when I was happily building a model with Keras, I found that there was an official function for drawing the model plot_model(), so I happily called the function keras.utils.plot_model(model, 'model.png', show_shapes=True), and the result was the following error:

InvocationException: GraphViz's executables not found
...
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.

I thought, was it because I didn’t install , pydot and graphviz?So I happily turned on PyCharm and loaded my virtual environment with pydot and graphviz, but it was still reporting an error.

then I shut myself up for a while. After I closed myself up, I went to baidu and Google to find a solution. Sure enough, many people met the same problem as me. According to the big guy [1], this is an environmental problem, the solution is to PIP install graphviz or something, or manually download the graphviz installation package on the official website, and then add the system environment variable Path, such as C:\Program Files (x86)\Graphviz2.38\bin something.

I thought this solution made sense, and I happily tried it out, and still got an error.

and then I shut myself down again and went back to looking for a solution. Some people [2] say that the order of installation is very important. First install pydot, then install graphviz; Someone [3] said to use keras.utils.vis_utils.plot_model instead of keras.utils.plot_model. In short, the feeling is not reliable.

finally, you guessed it, I uninstalled PyCharm and pydot in pydot ( PIP install pydot0) in PyCharm and pydot) in the pydot). Success!

then I thought about what was causing the error for a while, I tried to delete the system variable of graphviz, but the error didn’t occur. Oh, calculate, calculate, just work!

environment

  • Windows 10
  • Python 3.6
  • TensorFlow 2.0 Beta (built-in Keras)

effect

Reference

  1. Rob. (August 25, 2018). Graphviz and Pydotplus not working. Retrieved from https://datascience.stackexchange.com/questions/37428/graphviz-and-pydotplus-not-working
  2. web_ninja. (August 26, 13). Why is pydot unable to find GraphViz’s Executables in Windows 8?Retrieved from https://stackoverflow.com/questions/18438997/why-is-pydot-unable-to-find-graphvizs-executables-in-windows-8
  3. XifengGuo. (November, 6, 2017). pydot issue. Retrieved from https://github.com/XifengGuo/CapsNet-Keras/issues/7