File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+
3+ def print_python_imported_modules ():
4+ # print imported Python modules with their paths
5+ print (" ===== imported Python modules =====" )
6+ for module_name , module in sorted (sys .modules .items ()):
7+ try :
8+ module_file = module .__file__
9+ if module_file :
10+ print (f"{ module_name } : { module_file } " )
11+ except AttributeError :
12+ pass
13+
14+ def print_loaded_shared_libraries ():
15+ # print loaded shared libraries from /proc/self/maps
16+ print (" ===== loaded shared C/C++ libraries =====" )
17+ with open ("/proc/self/maps" , "r" ) as maps_file :
18+ lines = maps_file .readlines ()
19+ for line in lines :
20+ if ".so" in line :
21+ parts = line .split ()
22+ if len (parts ) > 5 :
23+ print (parts [5 ])
24+
25+ if __name__ == "__main__" :
26+ # import numpy
27+ # import pandas
28+
29+ print ("" )
30+ print_python_imported_modules ()
31+ print ("" )
32+ print_loaded_shared_libraries ()
33+ print ("" )
You can’t perform that action at this time.
0 commit comments