Django: djcelery Import error from celery import current_app as celery in virtualenv

青春壹個敷衍的年華 提交于 2020-01-14 14:12:05

问题


Okay so I have tried everything I and google can come up. I'm trying to run django-celery under a virtualenv on my Macbook Pro OSX 10.8.4. I installed django-celery using pip while the virtualenv was activated. I get the following when importing djcelery in virtualenv python.

(platform)Chriss-MacBook-Pro:platform Chris$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import djcelery
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Chris/Development/platform/lib/python2.7/site-packages/djcelery/__init__.py", line 25, in <module>
    from celery import current_app as celery  # noqa
ImportError: cannot import name current_app

I have tried to start a completely clean virtualenv but still seem to get the same error. I have tried upgrading the modules and have.

Here is also a list of my pip freeze packages.

BeautifulSoup==3.2.1
Django==1.5
MySQL-python==1.2.4c1
PIL==1.1.7
Pillow==2.0.0
amqp==1.0.12
anyjson==0.3.3
billiard==2.7.3.30
boto==2.9.6
celery==3.0.20
certifi==0.0.8
chardet==2.1.1
django-activelink==0.3
django-activity-stream==0.4.4
django-appconf==0.6
django-celery==3.0.17
django-compressor==1.2
django-debug-toolbar==0.9.4
django-flag==0.1.1
django-guardian==1.1.1
django-ses==0.4.1
django-tinymce==1.5.1
django-userena==1.2.0
easy-thumbnails==1.2
html5lib==1.0b1
jsonfield==0.9.13
kombu==2.5.12
oauthlib==0.1.3
pisa==3.0.33
pyPdf==1.13
pyasn1==0.1.7
python-dateutil==2.1
python-memcached==1.53
pytz==2013b
reportlab==2.7
requests==0.13.1
requests-oauth==0.4.1
rsa==3.1.1
six==1.3.0
vimeo-wrapper==0.0.2
wsgiref==0.1.2

Any help will be greatly appreciated!!


回答1:


So it seems there was a clash between something in djcelery and my project folders.

The folder structure I was using was something like this

\-project
--manage.py
--requirements.txt
\---platform
----app1
----app2
----etc

It seems the platform folder was colliding with something in the import as soon as I changed this the import started functioning correctly.

Thanks for all the help and comments.




回答2:


If you have a folder in your project called 'celery' rename it to something else. :)




回答3:


Did you wrote into the settings.py?:

INSTALLED_APPS = (
    ...
    'djcelery',
    ...
)

If you want work with Django's enviroment you must run console as

./manage.py shell

or

./manage.py shell --settings=path_to_settings_file_without_extention



来源:https://stackoverflow.com/questions/17371307/django-djcelery-import-error-from-celery-import-current-app-as-celery-in-virtua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!