How can I resolve PyCallGraphException: The command "dot -Tpng -failed with error code 256 error?

1.4k Views Asked by At

Trying to run the following command to make graph of calls using pycallgraph -

pycallgraph graphviz --output-file=/var/www/html/Reports/winmain.png -- token_check.py

But I am getting following error when I run the command.

pycallgraph.exceptions.PyCallGraphException: The command "dot -Tpng -o/var/www/html/Reports/winmain.png /tmp/tmpVDYnvE" failed with error code 256.

Note that I have both 'dot' & graphviz. Can anyone tell how can I resolve this issue?

This is the complete traceback-

Traceback (most recent call last):
File "/usr/bin/pycallgraph", line 26, in <module>
exec(__file_content)
File "/usr/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line   38, in __exit__
self.done()
File "/usr/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 81, in done
self.stop()
File "/usr/lib/python2.7/site-packages/pycallgraph/pycallgraph.py", line 90, in generate
output.done()
File "/usr/lib/python2.7/site-packages/pycallgraph/output/graphviz.py", line 112, in done
'code %(ret)i.' % locals())
 pycallgraph.exceptions.PyCallGraphException: The command "dot -Tpng -o/var/www/html/Reports/winmain.png /tmp/tmpVDYnvE" failed with error code 256.
1

There are 1 best solutions below

2
On

This worked for me

Go to /usr/lib/python2.7/site-packages/pycallgraph/output/graphviz.py

Add a space between -o and the argument. That is ,

Change around line 102

cmd = '{} -T{} -o{} {}'.format(
            self.tool, self.output_type, self.output_file, temp_name
        )

to

cmd = '{} -T{} -o {} {}'.format(
            self.tool, self.output_type, self.output_file, temp_name
        )