I went through this example here:
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
All my tasks are in files called tasks.py.
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'
I got the same error. It turns out there was a problem with my Celery version. I upgraded to 3.1 and celeryd is now deprecated for this version (http://celery.readthedocs.org/en/latest/whatsnew-3.1.html). So I had to downgrade to the version 3.0.19 that was the previous stable version used for the project, and it works good so far.
pip install celery==3.0.19
Anyway, if you don't want to downgrade, the replacement for celeryd in the version 3.1 is celery worker. Check here for more info: http://celery.readthedocs.org/en/latest/userguide/workers.html.
Hope this helps! :)
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
I got the same error.
Seems that from __future__ import absolute_import
DOES NOT work for Python 2.6.1, still not raising an error.
Upgraded to Python 2.7.5 and it just worked.
Did you add the line:
from __future__ import absolute_import
to the top of your cloud/celery.py
module?
Read the breakdown of the example here: http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
Note that older Django projects have the manage.py
script in the same directory as the project directory. That is, the structure looks like this:
- proj/
- proj/__init__.py
- proj/celery.py
- proj/urls.py
- proj/manage.py
- proj/settings.py
instead of this:
- proj/
- proj/__init__.py
- proj/celery.py
- proj/settings.py
- proj/urls.py
- manage.py
In this case, you will just have to rename the celery.app
file to something different, like celeryapp.py
as suggested in the accepted answer above.