I need to execute shell command in python program (I have ubuntu). More specifically I want to create graph using graphviz in python script. My code is
os.system("dot -Tpng graph.dot -o graph.png")
It does not work, but if I just type "dot -Tpng graph.dot -o graph.png" in command line then everything is fine. Do you know what the problem? Thank you!
Edit: does not work means that nothing happens, there are no errors.
Output from "dot -v -Tpng graph.dot -o graph.png"
dot - graphviz version 2.26.3 (20100126.1600)
Activated plugin library: libgvplugin_pango.so.6 Using textlayout: textlayout:cairo Activated plugin library: libgvplugin_dot_layout.so.6 Using layout: dot:dot_layout Using render: cairo:cairo Using device: png:cairo:cairo The plugin configuration file: /usr/lib/graphviz/config6 was successfully loaded. render : cairo dot fig gd map ps svg tk vml vrml xdot layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi textlayout : textlayout device : canon cmap cmapx cmapx_np dot eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg pdf plain plain-ext png ps ps2 svg svgz tk vml vmlz vrml wbmp x11 xdot xlib loadimage : (lib) eps gd gd2 gif jpe jpeg jpg png ps svg
os.system('/usr/bin/which dot')? - Emilio Silvadotis on your path, now tryos.system('dot -v -Tpng graph.dot -o graph.png')(that is, use-vfor verbose). - Emilio Silva-voption is to see ifdotgives some explanation as to why it does not create it. - Emilio Silva