【发布时间】:2013-06-26 14:47:54
【问题描述】:
好的,所以我已经尝试了我和谷歌可以提出的一切。我正在尝试在我的 Macbook Pro OSX 10.8.4 上的 virtualenv 下运行 django-celery。我在激活 virtualenv 时使用 pip 安装了 django-celery。在 virtualenv python 中导入 djcelery 时得到以下信息。
(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
我试图启动一个完全干净的 virtualenv,但似乎仍然遇到同样的错误。我已经尝试升级模块并且有。
这也是我的 pip freeze 包的列表。
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
任何帮助将不胜感激!
【问题讨论】:
-
你确定在 celery 模块中定义了 current_app 吗?
-
嗯,这就是我开箱即用的方式。我应该在哪里定义它?我在 celery 的第一步中没有看到任何东西 - docs.celeryproject.org/en/latest/django/… 关于定义它,所以我认为它应该可以工作。
-
好的,所以我设法弄清楚如果我在项目文件夹之外,导入 djcelery 可以工作,但在文件夹内时仍然无法工作。我不确定这会如何导致问题,因为项目文件夹中的环境没有任何改变。
-
其实是有区别的——如果你在virtualenv下,你可能需要修改sys.path。您可以发布您的 django 启动脚本 - 默认是 manage.py 吗?
-
感谢您的反馈,我设法找到了问题。在我的项目文件夹中,我有一个名为 platform 的主项目子文件夹。似乎这一定与我重命名它时导入开始工作时发生了冲突。感谢您的帮助。
标签: django celery virtualenv django-celery djcelery