3

I am using Python to create a graph via pydot.Dot.

When I want to write the graph to PNG, I use pydot.Dot.write_png(...). Unfortunately, it fails at the stage of finding graphviz (in a function called find_graphviz).

I tried installing it as a software but I don't see how it can be imported to Python.

How can I solve this problem?

ggorlen
  • 44,755
  • 7
  • 76
  • 106
yoki
  • 1,796
  • 4
  • 16
  • 27

2 Answers2

4

Even after adding Graphviz to my PATH, it wasn't working. I ended up going into the pydot.py file and commenting out everything in find_graphviz() and writing in the line:

`return {'dot': 'C:\\Program Files\\graphviz-2.38\\bin\\dot.exe'}`

That's where my dot file was located, you might have it in a different location.

eternalmothra
  • 221
  • 3
  • 12
1

Try manually adding the Graphviz\bin folder to your systems PATH.

>>> import pydot
>>> pydot.find_graphviz()
{'dot': 'C:\\Program Files (x86)\\Graphviz 2.28\\bin\\dot.exe'} #...
>>> print pydot.find_graphviz.__doc__
"""
Locate Graphviz's executables in the system.

    Tries three methods:

    First: Windows Registry (Windows only)
    This requires Mark Hammond's pywin32 is installed.

    Secondly: Search the path
    It will look for 'dot', 'twopi' and 'neato' in all the directories
    specified in the PATH environment variable.

    Thirdly: Default install location (Windows only)
    It will look for 'dot', 'twopi' and 'neato' in the default install
    location under the "Program Files" directory.

    It will return a dictionary containing the program names as keys
    and their paths as values.

    If this fails, it returns None.
"""
Txema
  • 849
  • 5
  • 15
  • Thanks. I did this, but I still get an error at the registry stage, ie it seems like a bug that occurred when it didn't find it in the registry, but didn't continue to the path search: # error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') # – yoki May 08 '13 at 20:36
  • Okay - I just added "and False" to line 432 in pydot.py so that it will just skip the registry part and go to the path method. – yoki May 09 '13 at 05:31