Python error “ImportError: No module named”

后端 未结 29 2680
野的像风
野的像风 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:55

    To all those who still have this issue. I believe Pycharm gets confused with imports. For me, when i write 'from namespace import something', the previous line gets underlined in red, signaling that there is an error, but works. However ''from .namespace import something' doesn't get underlined, but also doesn't work.

    Try

    try:
        from namespace import something 
    except NameError:
        from .namespace import something
    

提交回复
热议问题