1

can i list the python packages that are actually required for running exiting python program running in linux. I tried running following commands.

pip3 freeze 
pip3 list
ozil
  • 599
  • 7
  • 31
  • 2
    Does this answer your question? [Get all modules/packages used by a python project](https://stackoverflow.com/questions/35796968/get-all-modules-packages-used-by-a-python-project) – MLavrentyev Jul 14 '20 at 14:18

1 Answers1

1

To find the modules used by a single python script, you can try to use ModuleFinder:

Create a new python script to analyze the modules your script is using:

New Script:

from modulefinder import ModuleFinder

finder = ModuleFinder()
finder.run_script('MultiProcess.py')

print('Loaded modules:')
for name, mod in finder.modules.items():
    print(('%s: ' % name))
    print((','.join(list(mod.globalnames.keys())[:3])))

print(('-'*50))
print('Modules not imported:')
print(('\n'.join(iter(finder.badmodules.keys()))))

The output is very verbose and detailed

reference: https://docs.python.org/2/library/modulefinder.html

Donald S
  • 1,583
  • 1
  • 10
  • 26