Discover all non-standard library modules imported by a script

Malcolm Greene python at bdurham.com
Fri Sep 16 07:29:00 EDT 2016


Looking for suggestions on how, given a main script, discover all the
non-standard library modules imported across all modules, eg. the
modules that other modules import, etc. I'm not looking to discover
dynamic imports or other edge cases, just the list modules loaded via
"import <module>" and "from <module> import ...". I know I could write a
script to do this, but certainly there must be such a capability in the
standard library?

Use case: Discovering list of modules to use for building a Python 3.5
zipapp distributable.

Thank you,
Malcolm



More information about the Python-list mailing list