简体   繁体   中英

Python ImportError: No module named

I try to run django project, which has this kind of structure: 2 apps in one project:

projectx

├──apps
│  ├── app1
|  |    ├── __init__.py
|  |    └── ...
│  └── app2
|       ├── __init__.py
|       └── ...
├──project
│  ├── settings.py
│  ├── urls.py
│  ├── __init__.py
|  └── ...
├── manage.py
└── ...

It has two apps in one project. Well, while running python manage.py runserver I get ImportError: No module named apps

$ echo $PYTHONPATH gives
/home/alexander/Work/projectx

Django version 1.9.8

INSTALLED_APPS = [
...

'apps.app1',
'apps.app2'
]

You should add __init__.py inside your apps directory

    ├──apps
    ├──__init__.py
    │  ├── app1
    |  |    ├── __init__.py
    |  |    └── ...
    │  └── app2
    |       ├── __init__.py
    |       └── ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM