PyCharm unresolved reference when importing class from other file

后端 未结 5 1268
遇见更好的自我
遇见更好的自我 2021-01-11 11:00

This problem has been driving me nuts. I am trying to import a class from a file in the same directory. PyCharm is giving me the \"Unresolved reference\" error. MyClas

5条回答
  •  佛祖请我去吃肉
    2021-01-11 11:22

    If MyClass is defined in pack/file.py, you need to import it as:

    from pack.file import MyClass
    

    Note that using names of Python built-in types (such as file) for your own modules is a bad idea.

提交回复
热议问题