首页 > 解决方案 > 如何在子包中运行 django

问题描述

我的项目结果如下,django在automl/service,在automl/service/worker/suggester.py文件中有一个import from automl.core import util,这个文件是views.py导入的,运行python service/manage.py runserver的时候会抛出异常

from automl.core import util
ModuleNotFoundError: No module named 'automl'

如何解决这个问题,django不能在子包中运行吗?

├── automl
│   ├── __init__.py
│   ├── core
│   │   ├── __init__.py
│   │   └── base.py
│   ├── example
│   │   ├── __init__.py
│   │   └── demo.py
│   └── service
│       ├── __init__.py
│       ├── manage.py
│       ├── master
│       │   ├── __init__.py
│       │   └── urls.py
│       ├── settings.py
│       ├── worker
│       │   ├── __init__.py
│       │   ├── admin.py
│       │   ├── apps.py
│       │   ├── exceptions.py
│       │   ├── models.py
│       │   ├── suggester.py
│       │   ├── tests.py
│       │   ├── urls.py
│       │   └── views.py
│       ├── urls.py
│       └── wsgi.py
├── bin
├── build.sh
├── ci.yml
├── conf
│   └── log_config.json
└── docs

标签: pythondjangopython-3.xdjango-views

解决方案


推荐阅读