I’m facing the below error when I try to start the celery using the command celery -A blogger.celery worker. I’m running the command from my package directory where I have my celery.py
ModuleNotFoundError: No module named 'blogger'
————————
blogger/celery.py
from celery import Celery
from django.conf import settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blogger.settings")
app = Celery('blogger')
app.conf.enable_utc = Falseapp.conf.update(timezone='Asia/kolkata')
app.config_from_object(settings, namespace='CELERY')
——————
blogger/init.py
from .celery import app as celery_app
all = ('celery_app', )
————————
blogger/setting.py
CELERY_BROKER_URL = 'redis://127.0.0.1:6379'CELERY_ACCEPT_CONTENT = ['application/json']CELERY_RESULT_SERIALIZER = 'json'CELERY_TASK_SERIALIZER = 'json'CELERY_TIMEZONE = 'Asia/kolkata'CELERY_RESULT_BACKEND = 'django-db'CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'—————————
Please help me resolve this issue
Assuming your file structure looks like so:
blogger/
├─ blogger/
│ ├─ __init__.py
│ ├─ settings.py
│ ├─ celery.py
├─ app/
│ ├─ ...
You must run the command celery -A blogger worker
in the root folder (blogger/
NOT blogger/blogger/
). You will also need beat running which can be achieved with celery -A blogger beat
.
All this information can be found in the official celery docs.