Have you tried Inspect Shell[1]? All you have to do to monitor your script is include "import inspect_shell" in the 1st line of you source code and then run:
"python inspect_shell.py" When you get the prompt you can enter the following to show the list of modules: localhost:1234> '\n'.join(['{}={}'.format(k,v) for k,v in sys.modules.items()]) [1] https://github.com/amoffat/Inspect-Shell ________________________________ > Date: Wed, 22 May 2013 21:39:52 -0700 > Subject: Re: Modules list-tool > From: drsali...@gmail.com > To: gva...@broadpark.no > CC: python-list@python.org > > On Tue, May 21, 2013 at 12:35 PM, Gisle Vanem > <gva...@broadpark.no<mailto:gva...@broadpark.no>> wrote: > Are anyone aware of a tool that can show me at run-time > which modules (pyd/dll) are loaded into a Python program at a specific > time (or over time)? > > To clarify, e.g. when running a sample from PyQt4 > (examples\tutorials\addressbook\part1.pyw) and using Process Explorer [1], > I can launch WinDbg from it and get this list of modules: > .... > > ModLoad: 1d000000 1d00a000 G:\ProgramFiler\Python27\python.EXE > ModLoad: 7c900000 7c9b1000 F:\WINDOWS\system32\ntdll.dll > ModLoad: 7c800000 7c8f7000 F:\WINDOWS\system32\kernel32.dll > ModLoad: 1e000000 1e261000 f:\windows\system32\python27.dll > ModLoad: 7e410000 7e4a1000 F:\WINDOWS\system32\USER32.dll > ModLoad: 77f10000 77f59000 F:\WINDOWS\system32\GDI32.dll > ModLoad: 77dc0000 77e6a000 F:\WINDOWS\system32\ADVAPI32.dll > ModLoad: 77e70000 77f03000 F:\WINDOWS\system32\RPCRT4.dll > ModLoad: 77fe0000 77ff1000 F:\WINDOWS\system32\Secur32.dll > ModLoad: 7c9c0000 7d1d8000 F:\WINDOWS\system32\SHELL32.dll > ModLoad: 77c00000 77c58000 F:\WINDOWS\system32\msvcrt.dll > ModLoad: 77f60000 77fd6000 F:\WINDOWS\system32\SHLWAPI.dll > ModLoad: 78520000 785c3000 > f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCR90.dll > > ModLoad: 76370000 7638d000 f:\windows\system32\IMM32.DLL > ModLoad: 62f20000 62f29000 f:\windows\system32\LPK.DLL > ModLoad: 75420000 7548b000 f:\windows\system32\USP10.dll > ModLoad: 773c0000 774c3000 > f:\windows\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll > > ModLoad: 5d5d0000 5d66a000 F:\WINDOWS\system32\comctl32.dll > ModLoad: 78aa0000 78b5f000 f:\windows\system32\MSVCR100.dll > ModLoad: 00d90000 00f29000 > g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore.pyd > ModLoad: 67000000 67260000 > g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore4.dll > ModLoad: 774d0000 7760e000 F:\WINDOWS\system32\ole32.dll > ModLoad: 71aa0000 71ab7000 f:\windows\system32\WS2_32.dll > ModLoad: 71a90000 71a98000 f:\windows\system32\WS2HELP.dll > ModLoad: 78480000 7850e000 > f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCP90.dll > > ModLoad: 00a60000 00a73000 > g:\ProgramFiler\Python27\lib\site-packages\sip.pyd > ModLoad: 011f0000 0177f000 > g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui.pyd > ModLoad: 65000000 657c4000 > g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui4.dll > ... > > ------------- > > My example may be mooth since part1.pyw above (when I enter > the debugger) is just waiting for events. The stack of pythonw.exe as > shown in Process Explorer: > ... > ntdll.dll!ZwWaitForMultipleObjects+0xc > kernel32.dll!WaitForMultipleObjectsEx+0x12c > USER32.dll!RealMsgWaitForMultipleObjectsEx+0x13e > QtCore4.dll!QEventDispatcherWin32::processEvents+0x3c3 > ntdll.dll!RtlAcquirePebLock+0x28 > > Is there a tool that can do something similar? (written in Python > maybe?). But a bit simpler to use than my current method. Just launch > it from the command-line; something like "pyXX part1.pyw <more args>" > > [1] http://technet.microsoft.com/en-gb/sysinternals/bb896653 > > --gv > -- > http://mail.python.org/mailman/listinfo/python-list > > Python -v reports on modules. > > -- http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list