list python packages consumed by an application
<pre><code>def get_pkgs():
    pkgs = []
    for importer, modname, ispkg in \
            pkgutil.walk_packages(path=None, onerror=lambda x: None):
    pkgs.append(modname)
    return pkgs
</code></pre>

<p>Above code snippet gives me all python packages in distribution. Can someone suggest me a way to get all packages out of these used by a python application ?</p>
