Django Celery 导致 runserver 命令出现导入错误

发布于 2024-09-29 03:51:42 字数 2165 浏览 3 评论 0原文

当我发出 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2024-10-06 03:51:42

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文