dave dave - 1 year ago 174
Python Question

ImportError: No module named books.apps (Django)

I would like to use Django to create an app but got an error

"ImportError: No module named books.apps" after running:

python manage.py startapp books

Error message:

Traceback (most recent call last):
File "manage.py", line 22, in <module>
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/core/management/__init__.py", line 350, in execute_from_command_line
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/core/management/__init__.py", line 324, in execute
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/__init__.py", line 18, in setup
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
ImportError: No module named books.apps

Any idea what went wrong? Thanks!

Answer Source

You must first start a project before trying to start an app. First run:

python manage.py startproject mysite

and replace "mysite" with what you want to call your project. Then run:

python manage.py startapp books

See the docs here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download