Python error “ImportError: No module named”

后端 未结 29 2992
野的像风
野的像风 2020-11-22 07:46

Python is installed in a local directory.

My directory tree looks like this:

(local directory)/site-packages/toolkit/interface.py

29条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 07:57

    If you have tried all methods provided above but failed, maybe your module has the same name as a built-in module. Or, a module with the same name existing in a folder that has a high priority in sys.path than your module's.

    To debug, say your from foo.bar import baz complaints ImportError: No module named bar. Changing to import foo; print foo, which will show the path of foo. Is it what you expect?

    If not, Either rename foo or use absolute imports.

提交回复
热议问题