-2

I haven't been able to find any direct answers online. Would it just use the one closest to the file that's trying to import it? Is there some kind of priority system? Or would it just return an error?

  • As a debugging idea, create two of your own modules with the same name. Have each module print its path when imported. Then put them in local folder, python path, etc and see what gets imported first! – SNygard Jun 10 '21 at 13:24
  • 1
    Also, a related question is here: https://stackoverflow.com/questions/9586630/python-paths-and-import-order – SNygard Jun 10 '21 at 13:25
  • 2
    Does this answer your question? [Python import precedence: packages or modules?](https://stackoverflow.com/questions/4092395/python-import-precedence-packages-or-modules) – aaronn Jun 10 '21 at 13:29
  • 1
    @SNygard I tried that, and it worked! Apparently it uses the module closest to the file that's trying to import. – Redcoolhax Jun 10 '21 at 13:36

1 Answers1

0

Thanks to @SYngard's suggestion, I found out that the module imported will be the one closest (in terms of file paths) to the file that's trying to import a module by name.