pycallgraph with pycharm does not work on windows

3.2k Views Asked by At

I m using Windows 7, Python 3.4.1, Anaconda 2.0.1 , Pycharm 3.4.
Graphviz and dot work normally in the console.

However, when trying to use pycallgraph it finishes with an error.

"C:\Users\John\Anaconda3\python.exe" C:/PycharmProjects/myprojectname/abilities.py
Traceback (most recent call last):
  File "C:/PycharmProjects/myprojectname/abilities.py", line 1247, in <module>
    with PyCallGraph(output=GraphvizOutput()):
  File "C:\Users\John\Anaconda3\lib\site-packages\pycallgraph\pycallgraph.py", line 32, in __init__
    self.reset()
  File "C:\Users\John\Anaconda3\lib\site-packages\pycallgraph\pycallgraph.py", line 53, in reset
    self.prepare_output(output)
  File "C:\Users\John\Anaconda3\lib\site-packages\pycallgraph\pycallgraph.py", line 97, in prepare_output
    output.sanity_check()
  File "C:\Users\John\Anaconda3\lib\site-packages\pycallgraph\output\graphviz.py", line 63, in sanity_check
    self.ensure_binary(self.tool)
  File "C:\Users\John\Anaconda3\lib\site-packages\pycallgraph\output\output.py", line 97, in ensure_binary
    'The command "{}" is required to be in your path.'.format(cmd))
pycallgraph.exceptions.PyCallGraphException: The command "dot" is required to be in your path.

Process finished with exit code 1

What can i do to fix this?
I checked this but it's for mac.

1

There are 1 best solutions below

0
On

Please make sure you have the path for dot.exe in your PATH variable. In your computer properties, you can go to Advanced System Settings -> Advanced (tab) -> Environmental Variables then edit the PATH variable.

Make sure you have "C:\Program Files (x86)\Graphviz2.38\bin" (I just installed Graphviz so your path might be a little different) in your list. The list is semi-colon separated and you should not have a space in-between entries nor a trailing backslash.

My PATH environmental variable looks like:

C:\Users\<censored>\AppData\Roaming\npm;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files (x86)\Graphviz2.38\bin

And after re-opening a windows terminal, I was able to run pycallgraph like:

C:\Python27\python.exe C:\Python27\Scripts\pycallgraph --stdlib graphviz --output-file=ninja_mol2.png -- script.py "-f SampleDat/blah.txt -s stuff/ -v"

And that put a nice PNG in the current working directory I was in.

I hope this helps.