pythonpngdot

Converting dot to png in python


I have a dot file generated from my code and want to render it in my output. For this i have seen on the net that the command is something like this on cmd

dot -Tpng InputFile.dot -o OutputFile.png  for Graphviz

But my problem is that I want to use this inbuilt in my python program.

How can i do so ??

I looked at pydot but can't seem to find an answer in there.....


Solution

  • pydot needs the GraphViz binaries to be installed anyway, so if you've already generated your dot file you might as well just invoke dot directly yourself. For example:

    from subprocess import check_call
    check_call(['dot','-Tpng','InputFile.dot','-o','OutputFile.png'])