I have copied an example from their own website but i do not know how to get it working.
This is my code:
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
class Banana:
def eat(self):
pass
class Person:
def __init__(self):
self.no_bananas()
def no_bananas(self):
self.bananas = []
def add_banana(self, banana):
self.bananas.append(banana)
def eat_bananas(self):
[banana.eat() for banana in self.bananas]
self.no_bananas()
def main():
graphviz = GraphvizOutput()
graphviz.output_file = 'basic.png'
with PyCallGraph(output=graphviz):
person = Person()
for a in xrange(10):
person.add_banana(Banana())
person.eat_bananas()
if __name__ == '__main__':
main()
And this is the error i am receiving when trying to compile it:
File "test_pycallgraph.py", line 43, in <module>
main()
File "test_pycallgraph.py", line 35, in main
with PyCallGraph(output=graphviz):
'The command "{}" is required to be in your path.'.format(cmd))
pycallgraph.exceptions.PyCallGraphException: The command "dot" is required to be in your path.
It seems that the library you want to use makes an internal call to the the dot
command. But since dot
is not in your PATH, the library cannot find the dot
executable and raises an exception.
You most likely need to install dot
, which is a command line tool for drawing directed graphs. Make sure you have it installed.
If you already have it installed, make sure you add it’s location to your PATH. See this Stack Overflow answer for more information about modifying your PATH.