How to get current import paths in Python?

后端 未结 4 567
Happy的楠姐
Happy的楠姐 2020-12-08 03:50

I get an ImportError exception somewhere in the code, but the same module can be imported safely at startup of the application. I\'m curious to see which paths

4条回答
  •  庸人自扰
    2020-12-08 04:22

    Sys.path is a list of all the paths Python looks through when finding imports. If you want to add another path to a directory containing one or more python files, you can use: sys.path.append('path/to/directory').

提交回复
热议问题