1

I am trying to set up celery with Django on my development server, running on ubuntu. Following are changes i made.

init.py

from __future__ import absolute_import, unicode_literals

from .celery import app as celery_app

__all__ = ['celery_app']

celery.py

from __future__ import absolute_import
import os
from celery import task
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'samplecelery.settings')


app = Celery('samplecelery')

app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))

tasks.py

from __future__ import absolute_import
from celery import shared_task

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

@shared_task
def mul(x, y):
    return x * y

when i run the command to check the worker for samplecelery

celery -A sampleceleryworker -l info

app=Celery(samplecelery)

It tells me the app is not installed. Any thoughts on what might have gone wrong in this setup?can anyone please help me..... ModuleNotFoundError: No module named 'Celery'

7
  • You are missing an import for Celery in celery.py Commented Oct 24, 2018 at 22:36
  • But now i'm getting this following error in tasks.py is from Celery import shared_task ImportError: No module named 'Celery' Commented Oct 25, 2018 at 6:04
  • Plz update your code above with what you have now so I can see it. Commented Oct 25, 2018 at 6:35
  • i have updated the code. when i run the celery worker i'm getting this following error.. app.config_from_object('django.conf:settings', namespace='CELERY') TypeError: config_from_object() got an unexpected keyword argument 'namespace' and also i'm new to this how to call the tasks. Commented Oct 25, 2018 at 10:10
  • What version of celery are you using? Can you check with pip freeze? Commented Oct 25, 2018 at 10:13

1 Answer 1

1

to resolve this error

TypeError: config_from_object() got an unexpected keyword argument 'namespace'

the solution is here.you need to:

pip install celery==4.2.0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.