I was wondering whether anybody had come across a tool that can have a stab at depicting the control flow of a Python application - for instance, identifying the entry point(s) to a project, and identifying what code units are called from it.

As a more crude version, something which just maps the hierarchy of module imports would be handy. That gives you a lower resolution version of the above.

PS: I know that such a tools is not likely to provide results good enough for documentation purposes - I just want something to point me in the right direction, rather than trawling through the code with a clean sheet of paper...

  • 1
    Somewhat related : Visualize call graphs for Python Jan 9, 2020 at 10:43
  • @MawgsaysreinstateMonica Very similar - i was just searching for different terminology :-( Jan 9, 2020 at 11:22
  • 1
    I hope that one of these gets an answer, as I would like to see it too :-) DoxyGen seems like a god way to go. I have used it for decades now, both privately & professionally & highly recommend it, if you don't already know it Jan 9, 2020 at 11:28
  • 1
    I've used Doxygen for many years, but I hadn't realised that it had a caller graph functionality. Jan 9, 2020 at 12:56

1 Answer 1


I feel slightly guilty here for just capitalising on @MawgsaysreinstateMonica 's comments, which gives most of the answer, but I thought I'd just formalise it for another reader's benefit.

  1. Install Doxygen.
  2. Install Graphviz, and add its 'bin' directory
  3. Run up Doxywizard, and select the "Call graphs" and "Called by graphs" options (these are unticked by default)

This produces perfectly adequate call graphs, although they seem to get confused by Python's

if __main__:

clause. I just commented it out while producing the diagrams.

  • "I feel slightly guilty here for just capitalising on @MawgsaysreinstateMonica 's comments" - MawgsaysreinstateMonica says "don't" :-) MawgsaysreinstateMonica was too lazy to post a full answer. You did. You helped others. Well done. Thanks for doing what I was too lazy to Sep 28, 2022 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.