按照芹菜样品的步骤,总是给我进口芹菜的错误

  • 本文关键字:芹菜 错误 python 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作为broker。。。

from celery import Celery
app = Celery('tasks', broker='redis://localhost:6379//0')
@app.task
def add(x, y):
    return x + y

我真的不知道这个问题背后是什么,你能解释一下吗?

尝试更改代理url

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

请注意,它应该是0 之前的一个斜线

编辑

或者尝试正确配置redis

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

何处

redis://:password@hostname:port/db_number

参考文件

然后用称之为

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

最终解决了这个问题。tasks.py应更改为:

from celery import Celery
celery = Celery('tasks', broker='redis://localhost:6379')
@celery.task
def add(x, y):
    return x + y

顺便问一下,这是芹菜教程的错误吗?我不知道。。。

相关内容

  • 没有找到相关文章

最新更新