Adding : python -c 'help("modules") to the other two suggestions:
#!/usr/bin/env python import commands, pkgutil, re, sys print('sys.modules.items()...') print('\n'.join(sorted([re.findall("from '(.*)'",str(v))[0] for k,v in sys.modules.items() if str(v).find('from')>-1]))) print('\npkgutil.iter_modules()...') toplevel_packages = ['%s\\%s'%(ml.path,name)for ml,name,ispkg in sorted(pkgutil.iter_modules()) if ispkg] print '\n'.join(toplevel_packages) theCommand = "python -c 'help(\"modules\")'" print('\n{} # this may take a few seconds...'.format(theCommand)) print(commands.getstatusoutput(theCommand)[1]) # help() only works in the python interpreter... -- http://mail.python.org/mailman/listinfo/python-list