I'm using Django, Celery, and RabbitMQ. When I run celery -A FlakeFinder worker -l INFO
from the top level directory, I get the error:
Usage: celery [OPTIONS] COMMAND [ARGS]...
Error: Invalid value for '-A' / '--app':
Unable to load celery application.
Module 'flakefinder' has no attribute 'celery'
If I instead run celery -A FlakeFinder.celeryApp worker -l INFO
, I get this error in purple text:
ModuleNotFoundError: No module named 'celery.backends.amqp'
I'm not really sure where to go from here. How can I get the celery worker running?
My folder structure looks like this:
. (FlakeFinder)
├── FlakeFinder
│ ├── __init__.py
│ ├── asgi.py
│ ├── celeryApp.py
│ ├── secrets.py
│ ├── settings.py
│ ├── tasks.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── license.txt
├── manage.py
├── scraping
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── models.py
│ ├── scraper.py
│ ├── tests.py
│ └── views.py
celeryApp.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab # scheduler
# default django settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FlakeFinder.settings')
app = Celery('FlakeFinder')
app.conf.timezone = 'UTC'
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()
app.conf.beat_schedule = {
# executes every 1 minute
'scraping-task-three-hr': {
'task': 'scraping.tasks',
'schedule': crontab()
}
}
tasks.py
from scraping.scraper import *
from celeryApp import app
@app.task
def update_snow_locs():
...
I couldn't figure out how to get past this. I solved the issue by downgrading to version 4.4.2.