Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2838  / 2 Years ago, wed, january 19, 2022, 3:53:16

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

More From » python

 Answers
2

I figured out the problem. I should close file graph.dot before executing the command.


[#40062] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
losbu

Total Points: 71
Total Questions: 124
Total Answers: 106

Location: Honduras
Member since Sat, Jul 24, 2021
3 Years ago
losbu questions
Mon, Jan 31, 22, 21:41, 2 Years ago
Tue, Nov 22, 22, 01:27, 1 Year ago
Wed, Jan 25, 23, 00:28, 1 Year ago
Wed, May 11, 22, 08:41, 2 Years ago
;