Python 导入即使使用_uinit__uu.py文件也不起作用
我不断得到错误: ModuleNotFoundError:没有名为“helpers”的模块 我的结构如下:Python 导入即使使用_uinit__uu.py文件也不起作用,python,python-import,Python,Python Import,我不断得到错误: ModuleNotFoundError:没有名为“helpers”的模块 我的结构如下: basefolder |- main.py |- helpers |- __init__.py |- connection.py |- datasource.py my main.py具有以下代码: from helpers import * 我已尝试将\uuuu init\uuuu.py文件留空。我还尝试将以下代码添加到\uu
basefolder
|- main.py
|- helpers
|- __init__.py
|- connection.py
|- datasource.py
my main.py具有以下代码:
from helpers import *
我已尝试将\uuuu init\uuuu.py
文件留空。我还尝试将以下代码添加到\uuuu init\uuuuuuu.py
from helpers.connection import get_conn
from helpers.datasource import get_data
from .helpers import *
什么都不管用,我快发疯了。:) 您可以在
main.py
from helpers.connection import get_conn
from helpers.datasource import get_data
from .helpers import *
我假设
helpers
是helpers.py
,而您只是在结构中拼错了它,对吗?请尝试从.connection导入get_conn在\uu init\uuuuu.py
@Vadimhelpers
是一个文件夹,我猜拼写正确。您需要在基本文件夹内另一个\uuuu init\uuuuuuuuuuy.py
告诉Python从当前目录导入。@Vadim helpers是一个文件夹。尝试了这个,获取以下内容:ModuleNotFoundError:没有名为“\uuu main\uuuu.helpers”的模块__main__u;不是一个包