当我发出 runserver 命令时,会从 djcelery (Django Celery) 引发 ImportError。
% python manage.py runserver
~/Workspace/django-projects/no-labels/src
Validating models...
Unhandled exception in thread started by <function inner_run at 0x1ef7320>
Traceback (most recent call last):
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name)
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/damon/Workspace/django-projects/no-labels/env/lib/python2.6/site-packages/djcelery/models.py", line 14, in <module>
from celery.app import default_app
ImportError: No module named app
在 python 控制台中手动尝试导入 celery.app.default_app 时会出现同样的问题:
>>> from celery.app import default_app
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named app