2

How can I know the importing node path of a module?

For example, if I do

import xxx.xxx

Then somehow module yyy gets imported.

How can I know the path of the imports of yyy? something like

xxx.xxx -> zzz -> aaa -> yyy

milanbalazs
  • 4,811
  • 4
  • 23
  • 45
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
  • Maybe you can use listing multiple times: https://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package – HK boy Aug 05 '19 at 08:52
  • 1
    No, that is different question. that question is talking about how to find modules starting from a root. My question is the other way around, `how to find the path to root from a leaf` – Jackson Tale Aug 05 '19 at 08:55
  • Oh, sorry about that. – HK boy Aug 05 '19 at 08:57
  • You want to know the import chain to a leaf with code that is located in your leaf? – MofX Aug 05 '19 at 09:52

2 Answers2

4

If you start Python with the -vv flag then you will see verbose logs, including everything it tries to import.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
0

Just to know the path using python just use

import sys
print(sys.path)

check all the modules available in site-packages only if you want to explore libraries manually