Search code examples
pythonimportdependencies

List all dependencies of a Python file


Lets suppose I have a Python file(A.py) which is dependent on some pip modules (lets say numpy, tensorflow) and some other user modules in the package (lets say B.py, ../otherfolder/C.py etc.)

I want to list all these dependencies. I tried searching a lot but couldn't find any tool for this. Also it would be a bonus if it could also recursively list B.py and C.py dependencies. Thus at last I shall have the list of all all pip modules and user modules required to run A.py.

snakefood was one such tool for this purpose but it was last updated 13 years ago and doesn't support Python3

Thanks.


Solution

  • I guess you can use the ModuleFinder. You can check this link and the official doc for it.