部署到Azure后无法导入Celery

时间:2019-08-30 15:02:33

标签: python django azure celery

可能是一个非常熟悉的故事,具有可预测的结果,这将是一个Path问题,但我不知所措。

使用Celery的非常简单的Django应用程序(当前版本甚至都没有尝试运行Tasks,我只是想使Django应用程序与导入的Celery模块一起运行)。

按照标准说明。我项目的__init__.py文件包含

from __future__ import absolute_import, unicode_literals

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.

from .celery_setup import app as celery_app

__all__ = ('celery_app',)

请注意,通常的celery.py重命名为celery_setup,因为其他帖子暗示这可能是导入问题的原因。

celery_setup.py中,有问题的导入语句是:

from celery import Celery

使用venv在本地运行完全没有问题,并且拾取并加载了Celery模块。

但是,在部署到Azure WebApp之后,我只能看到命中wsgi.py文件的日志消息,当它寻找Celery模块时才得以纾困。

这是给与错误的: ImportError: cannot import name 'Celery' from 'celery' (/home/site/wwwroot/antenv/lib/python3.7/site-packages/celery/__init__.py)

使用Kudu,我可以验证此路径是否存在以及文件是否存在...

DJANGO_MODULE_SETTINGS已设置,所以我不认为那样。

0 个答案:

没有答案