我知道这可能很容易解决,但我不知道答案。
我的python3项目中具有以下文件夹结构:
---UserInterface
------__init__.py
------MainApplication.py
------StartPage.py
(附言:我的__init__.py为空)
现在,我要将StartPage添加到我的MainApplication中,然后尝试以下导入。
from . import StartPage
我收到以下错误:ImportError:无法从“ __main__”导入名称“ StartPage”。
谁能告诉我导入的问题在哪里? (我的主要方法在MainApplication.py中)
did you just try
import StartPage
? the error text says that there is noStartPage
inmain
. You runMainApplication
and it gets the namemain
after launch. This means that an attempt is being made to importStartPage
from theMainApplication
. But it's not there