The Fix
pip install celery==5.2.0rc2
Based on closed celery/celery issue #6558 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -262,6 +262,12 @@ you should import `kombu.utils.encoding` instead.
from the `celery` module instead.
+If you were using `from celery.task import Task` you should use
+`from celery import Task` instead.
+
from celery import shared_task
@shared_task
def add(x, y):
return x + y
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install celery==5.2.0rc2\nWhen NOT to use: This fix is not applicable if the code relies on the deprecated module for functionality.\n\n
Why This Fix Works in Production
- Trigger: no module named celery.task
- Mechanism: Updated documentation to reflect the removal of the deprecated celery.task module and provided guidance on using shared_task instead.
- Why the fix works: Updated documentation to reflect the removal of the deprecated celery.task module and provided guidance on using shared_task instead. (first fixed release: 5.2.0rc2).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Surfaces as: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\n File "<frozen importlib._bootstrap>", line…
Proof / Evidence
- GitHub issue: #6558
- Fix PR: https://github.com/celery/celery/pull/6981
- First fixed release: 5.2.0rc2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.52
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“from celery import Task this works !image”
“@auvipy but that's not a decorator !image”
“So in summary, we can use the 'shared_task' decorator in place of 'tasks'? .”
“yes https://github.com/celery/celery/blob/master/celery/app/__init__.py#L25”
Failure Signature (Search String)
- no module named celery.task
Error Message
Stack trace
Error Message
-------------
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\n File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 680, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 790, in exec_module\n File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed\n File "C:\Users\acer\Desktop\django\open source\dj-blog\src\dj-bitcoin-tracker-api\prices\tasks.py", line 5, in <module>\n **from celery.task.schedules import crontab
Minimal Reproduction
from celery import shared_task
@shared_task
def add(x, y):
return x + y
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install celery==5.2.0rc2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/celery/celery/pull/6981
First fixed release: 5.2.0rc2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the code relies on the deprecated module for functionality.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 5.2.0rc2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.