Django Celery 导致 runserver 命令出现导入错误
当我发出 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
When I issue a runserver command, an ImportError is raised from djcelery (Django Celery).
% 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
The same issue occurs when manually trying to import celery.app.default_app in the python console:
>>> from celery.app import default_app
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named app
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
celery.app
于 9 月 14 日才添加。您需要运行此后发布的 celery 副本。celery.app
was only added on September 14. You'll need to be running a copy of celery released since then.