Unable to Import Celery Modules

advertisements

I have a weird problem, I successful installed celery, but I can't import its modules:

>>> import celery   # OK

>>> import djcelery

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/django_celery-2.5.5-py2.7.egg/djcelery/__init__.py", line    25, in <module>
from celery import current_app as celery  # noqa
ImportError: cannot import name current_app

>>> from celery.decorators import task

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named decorators

this error occurs on celery 2.6.0a3 (from github) or 2.5.3 (from pypi) and django-celery 2.5.5. Tried re-installing several times, and even tried in Jython and I got the same error.

I have no clue what it is, can anyone help me out?


honestly, there is a better answer, which I wrote about here.

It's gotta do with a mismatch between your system python (and particularly, with the python standard lib "os") and your precompiled virtualenv python binary.

Deactivating virtualenv, deleting your virtualenv python binary, and then running the virtualenv script on the same virtualenv folder will recompile python for your virtualenv and fix the issue.