Prometheus Prometheus - 1 year ago 284
Python Question

Celery ImportError: No module named proj

I'm trying to setup Celery with Django. I have followed the guide:


from __future__ import absolute_import

import os

from celery import Celery

from django.conf import settings

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

app = Celery('proj')

# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

then in...


from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app


from __future__ import absolute_import

from celery import shared_task

def add(x, y):
return x + y

Then run:

celery -A proj worker -l info

which gives the error:

File "/Users/user/Documents/workspace/test-api/env/lib/python2.7/site-packages/kombu/utils/", line 92, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/Users/user/Documents/workspace/test-api/env/lib/python2.7/site-packages/celery/utils/", line 101, in import_from_cwd
return imp(module, package=package)
File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/", line 37, in import_module
ImportError: No module named proj

Answer Source

Your project is named project, not proj. You should use that name throughout.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download