Skip to content
Latchkey

Celery "Unable to load celery application" / Import Error in CI

The celery CLI imports the app object named by -A/--app. If that dotted path is wrong, the package is not importable from the working directory, or importing it triggers a failing side-effect, Celery cannot load the app.

What this error means

A celery -A proj worker (or a celery inspect/celery beat) step fails with Unable to load celery application and a ModuleNotFoundError or AttributeError for the app path. The app runs locally where the cwd and PATH differ.

Celery output
Error:
Unable to load celery application.
The module proj was not found.

Common causes

Wrong -A application path

The -A value must be the importable dotted path to the Celery app (e.g. proj.celery:app). A wrong module or attribute name fails the import.

Package not on sys.path in CI

If CI runs from a different directory or the project is not installed (pip install -e .), the app module is not importable and Celery cannot find it.

Import-time side effect fails

Importing the app triggers settings/DB access that is not configured in CI, raising during import rather than at runtime.

How to fix it

Use the exact importable app path

Terminal
# proj/celery.py defines: app = Celery("proj")
celery -A proj.celery:app inspect ping

Make the project importable

Install the project (editable) or set PYTHONPATH so the app module resolves regardless of cwd.

Terminal
pip install -e .
# or
PYTHONPATH=. celery -A proj worker --loglevel=info

Configure import-time dependencies for CI

  1. Provide settings/env the app needs at import (broker URL, settings module).
  2. Avoid doing network/DB work at module import; defer to task run time.
  3. Verify with python -c "import proj.celery" before invoking the CLI.

How to prevent it

  • Reference the full module:attr app path in CI invocations.
  • Install the project editable so imports are cwd-independent.
  • Keep app module import side-effect-free.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →