我正在使用python3.4中的flask项目,我的项目结构如下所示,
|-- venv
|-- web
|--admin
|--settings
|--custom_settings.py
|--script.py
这里的venv文件夹是python3虚拟环境,带有烧瓶&安装了等模块。
在script.py文件中的,我试图从设置包导入模块,如下所示,
from admin.settings.custom_settings import db, Role, Users
但是当我尝试执行脚本时,我收到错误
user@mint ~/PRJ/web $ ../../venv/bin/python3 script.py
Traceback (most recent call last):
File "script.py", line 23, in <module>
from admin.settings.custom_settings import db, Role, User
File "/home/user/PRJ/web/admin/__init__.py", line 19, in <module>
admin.settings.custom_settings import db, Role, User
ImportError: No module named 'settings'
从sys.path输出
/home/user/PRJ/admin/web
/home/user/PRJ/admin
/home/user/PRJ/venv/lib/python3.4
/home/user/PRJ/venv/lib/python3.4/plat-x86_64-linux-gnu
/home/user/PRJ/venv/lib/python3.4/lib-dynload
/usr/lib/python3.4
/usr/lib/python3.4/plat-x86_64-linux-gnu
/home/user/PRJ/venv/lib/python3.4/site-package
请让我知道我在这里做错了什么。