Django, ImportError: cannot import name Celery, possible circular import?

Adding the following lines to cloud/celery.py:

import celery
print celery.__file__

gave me the file itself and not the celery module from the library. After renaming celery.py to celeryapp.py and adjusting the imports all errors were gone.

Note:

That leads to a change in starting the worker:

celery worker --app=cloud.celeryapp:app

For those running celery==3.1.2 and getting this error:

TypeError: unpack_from() argument 1 must be string or read-only buffer, not memoryview

Apply the patch mentioned here: https://github.com/celery/celery/issues/1637


With Django 1.7.5, Celery 3.1.17, and Python 2.7.6 I found that I was still getting these ImportError: cannot import name Celery. But only when running tests under PyCharm 4.0.4.

I found that a solution was not to rely on from __future__ import absolute_import as described in First Steps with Django. Instead I renamed proj/proj/celery.py to proj/proj/celery_tasks.py and then changed the content of __init__.py to match: from .celery_tasks import app as celery_app. No more multiple instances of files named celery.py to cause import confusion seemed to be a simpler approach.


got the same error

my celery settings filename which was(celery.py) was conflicting with 'celery' package...

so while doing this-> from celery import Celery , it was raising error- cannot import name Celery

solution->just change the 'celery.py' to something else like 'celery-settings.py'


Work for me ( some bug after deploy in server ): Remove all *.pyc files from project and restart him.