pythonpython-3.xgraphvizassertionpydot

Assertion error while drawing graph with pydot


I just started using pydot to create a graph. I just created a single node, but while tring to display the graph using jupyter notebook I'm having an issue. This is my code:

import pydot
import os
from IPython.display import Image, display
G= pydot.Dot(graph_type='digraph')
node = pydot.Node("S'->.S\nS->.(L)/.a")
G.add_node(node)
im = Image(G.create_png())
display(im)

And the following my error

"dot" with args ['-Tpng', 'C:\\Users\\MAYANK~1\\AppData\\Local\\Temp\\tmptw6hrboj'] returned code: 1

stdout, stderr:
 b''
b"'C:\\Users\\Mayank' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-10-fb336e9303b4> in <module>
      5 node = pydot.Node("S'->.S\nS->.(L)/.a")
      6 G.add_node(node)
----> 7 im = Image(G.create_png())
      8 display(im)

~\anaconda3\lib\site-packages\pydot.py in new_method(f, prog, encoding)
   1721                 """Refer to docstring of method `create`."""
   1722                 return self.create(
-> 1723                     format=f, prog=prog, encoding=encoding)
   1724             name = 'create_{fmt}'.format(fmt=frmt)
   1725             self.__setattr__(name, new_method)

~\anaconda3\lib\site-packages\pydot.py in create(self, prog, format, encoding)
   1943             print(message)
   1944 
-> 1945         assert process.returncode == 0, process.returncode
   1946 
   1947         return stdout_data

AssertionError: 1

Please help me clear this error !!


Solution

  • I can't comment because of reputation, but I can say that when

    pos = graphviz_layout(temp_nx, prog="dot")
    

    gave me an assertion error, that

    pos = nx.nx_agraph.pygraphviz_layout(temp_nx, prog='dot')
    

    worked