2013-06-28 58 views
2

好吧,所以我已經嘗試了所有我和谷歌可以上來。我試圖在我的Macbook Pro OSX 10.8.4上的virtualenv下運行django-celery。當virtualenv被激活時,我使用pip安裝了django-celery。在virtualenv python中導入djcelery時,我得到以下內容。Django:djcelery從芹菜導入current_app導入錯誤作爲芹菜在virtualenv

(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凍結包的列表。

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 

任何幫助將不勝感激!

+0

你確定current_app是在芹菜模塊中定義的嗎? – ElmoVanKielmo

+0

嗯,這是我從盒子裏拿出來的。我應該在哪裏定義它?我沒有在芹菜的第一步看到任何東西 - http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html#configuring-your-django-project-to-use-芹菜關於定義它,所以我會認爲它應該工作。 –

+0

好吧,我設法弄清楚,如果我在我的項目文件夾之外,導入djcelery可以工作,但在文件夾內部時仍然無法工作。我不確定這是如何導致問題的,因爲沒有任何內容會改變項目文件夾中的環境。 –

回答

2

所以看起來有djcelery和我的項目文件夾中的東西之間的衝突。

我使用的文件夾結構是這樣的

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

看來platform文件夾與在進口的東西,一旦發生碰撞,因爲我改變了這種進口開始正常運行。

感謝您的幫助和意見。

-1

難道你寫到settings.py

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

如果你想與Django的環境工作,你必須運行控制檯

./manage.py shell

./manage.py shell --settings=path_to_settings_file_without_extention

1

如果您的項目中有一個名爲'celery'的文件夾,請將其重命名爲其他名稱。 :)