2014-10-17 67 views
0

我跟着芹菜教程Celery一步一步,按照芹菜樣品步驟,總是給我進口芹菜錯誤

但是經過我執行命令:celery -A tasks worker --loglevel=info,它總是給我一個錯誤。

這裏是堆棧:

File "/usr/local/bin/celery", line 9, in <module> 
    load_entry_point('celery==3.0.24', 'console_scripts', 'celery')() 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/__main__.py", line 14, in main 
    main() 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/bin/celery.py", line 957, in main 
    cmd.execute_from_commandline(argv) 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/bin/celery.py", line 901, in execute_from_commandline 
    super(CeleryCommand, self).execute_from_commandline(argv))) 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/bin/base.py", line 185, in execute_from_commandline 
    argv = self.setup_app_from_commandline(argv) 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/bin/base.py", line 300, in setup_app_from_commandline 
    self.app = self.find_app(app) 
    File "/usr/local/lib/python2.7/dist-packages/celery-3.0.24-py2.7.egg/celery/bin/base.py", line 318, in find_app 
    return sym.celery 
AttributeError: 'module' object has no attribute 'celery' 

的tasks.py只是跟着樣品,不同的是我使用的Redis的經紀人......

from celery import Celery 

app = Celery('tasks', broker='redis://localhost:6379//0') 

@app.task 
def add(x, y): 
    return x + y 

我真的沒有想法這個問題背後是什麼,你能解釋一下嗎?

回答

0

稱它爲最後解決問題。 tasks.py應改爲:

from celery import Celery 

celery = Celery('tasks', broker='redis://localhost:6379') 

@celery.task 
def add(x, y): 
    return x + y 

順便問一下,這是芹菜教程的錯誤嗎?我不知道...

0

試圖改變券商網址

app = Celery('tasks', broker='redis://localhost:6379/0') 

注意,它應該是一個斜槓前0

編輯

或嘗試正確配置的Redis

BROKER_URL = 'redis://localhost:6379/0' 

在哪裏

redis://:[email protected]:port/db_number 

Reference to docs

然後用

app = Celery('tasks', broker='redis://localhost//') 
+0

謝謝你的回答,但它仍然無法工作:( – liuzhidong 2014-10-17 23:17:25