What's an easy way of finding all the python modules from a particular package that are being used in an application?
Python modules can get access to code from another module by importing the file/function using import.
Running "python -v"from the command line tells you what is being imported and from where. This is useful if you want to know the location of built in modules.
We can also use the inspect module in python to locate a module. We will use inspect. getfile() method of inspect module to get the path. This method will take the module's name as an argument and will return its path.
Usually in /lib/site-packages in your Python folder. (At least, on Windows.) You can use sys. path to find out what directories are searched for modules.
sys.modules
is a dictionary mapping module names to modules. You can examine its keys to see imported modules.
See: http://docs.python.org/library/sys.html#sys.modules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With