Using Python 2.7 and Celery 3.1.25 on Windows, when we run the Celery worker using
celery -A proj worker -l info we get the error
ImportError: No module named celery Problem: The worker stops working when we
- changed the name of the file
celeryApp.pyfromcelery.py - changed the import statement in
tasks.pyfromfrom .celery import apptofrom celeryApp import app.
Why is this happening? How can we fix the problem?
Directory structure
/proj/__init__.py /proj/celeryApp.py /proj/tasks.py /proj/celeryApp.py
from __future__ import absolute_import, unicode_literals from celery import Celery app = Celery('tasks', broker='amqp://jack:jack@192.168.1.26:5672//', backend='amqp://', include=['proj.tasks']) if __name__ == '__main__': app.start() /proj/tasks.py
from __future__ import absolute_import, unicode_literals from celeryApp import app @app.task def add(x, y): return x + y