I wanted a quick, easy way to generate a dependency graph for PHP include statements, but of course I actually did my Google searches for a Python dependency visualizer. The PHP can wait …
Anyway, I found this cool page that had some scripts that can make dependency graphs using Python import statements.
In a nutshell, here's what I did.
- Made a folder on my Desktop (I have Window 7) called "python_visualizer".
- Downloaded py2depgraph.py and depgraph2dot.py to the folder.
- Downloaded and installed Graphviz.
- On my system it installed to:
- C:\Program Files\Graphviz2.26.3
- On my system it installed to:
- Put a copy of one of my Python scripts (renamed to "foo.py") in the "python_visualizer" folder.
- Opened the command line and did this:
$ python_visualizer>python py2depgraph.py foo.py | python depgraph2dot.py | "C:\Program Files\Graphviz2.26.3\bin\dot" -T png -o depgraph.png
Now, I did get a little error message as below:
(dot.exe:7244): Pango-WARNING **: couldn't load font "Helvetica Not-Rotated 10", falling back to "Sans Not-Rotated 10", expect ugly output.
but it's no big deal, the PNG still got made … and I don't think it's that ugly!
But you can judge for yourself …
--------------