Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

348
Vistas
Django: Celery can't find my app
ModuleNotFoundError: No module named 'myapp'

I'm not really understanding what the problem is here. There are no issues with my app, but celery can't seem to find it no matter what I try and change.

Here is my directory structure:

django
 / mysite
     __init__.py
     celery.py
     settings.py
     urls.py
     wsgi.py
     / myapp
       admin.py
       apps.py
       models.py
       tasks.py
       urls.py
       views.py
   manage.py

celery.py:

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

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

app = Celery('myapp')

# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()


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

Command: celery -A myapp worker -l info

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Make sure that your init.py file contains the following:

from __future__ import absolute_import, unicode_literals

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

__all__ = ['celery_app']

Also, make sure that your celery.py looks something along the lines of this

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from celery.schedules import crontab
import mysite

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

app = Celery('wellfie')

# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()


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

Make sure that your tasks are properly recognized as well: for instance a shared task would look like

@shared_task(name="mysite.myapp.tasks.simple_task") Edit.

Actually you need to move the myapp out of mysite and into the Django folder. I would rename the Django folder to mysite as well, so that you have the parent folder mysite, child folder mysite, that holds wsgi, celery, settings etc, child folder myapp

over 4 years ago · Santiago Trujillo Denunciar

0

Your celery.py file should be in myapp folder. (http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html)

You should run celery -A myapp worker -l info in mysite folder.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda