【发布时间】:2018-07-05 16:02:02
【问题描述】:
我是 celery 和 python 的新手,我想使用 celery 在应用程序中执行异步任务。 虽然我试图查看它是如何工作的,但演示应用程序本身并不能在我的本地设置上运行。 我在系统本地启动 rabbitmq 服务器,默认配置:用户:guest,密码:guest,默认端口为 5672。
我从http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html中挑选了示例代码
from celery import Celery
app = Celery('tasks', broker='amqp://guest:guest@localhost:5672/hello')
@app.task
def add(x, y):
return x + y
所有这些都已完成并放置在 virtualenv 中。然后我在包含 app.py 文件的文件夹位置并使用命令: celery -A tasks worker --loglevel=info 从终端运行 celery worker。 执行命令后得到如下输出:
Traceback (most recent call last):
File "/usr/local/bin/celery", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/celery/__main__.py", line 13, in main
from celery.bin.celery import main as _main
File "/Library/Python/2.7/site-packages/celery/bin/__init__.py", line 2, in <module>
from .base import Option
File "/Library/Python/2.7/site-packages/celery/bin/base.py", line 17, in <module>
from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
File "/Library/Python/2.7/site-packages/celery/local.py", line 509, in __getattr__
module = __import__(self._object_origins[name], None, None, [name])
File "/Library/Python/2.7/site-packages/celery/app/__init__.py", line 5, in <module>
from celery import _state
File "/Library/Python/2.7/site-packages/celery/_state.py", line 15, in <module>
from celery.utils.threads import LocalStack
File "/Library/Python/2.7/site-packages/celery/utils/__init__.py", line 9, in <module>
from .functional import memoize # noqa
File "/Library/Python/2.7/site-packages/celery/utils/functional.py", line 11, in <module>
from kombu.utils.functional import (
ImportError: cannot import name LRUCache
使用的依赖项: amqp 2.2.2、台球 3.5.0.3、芹菜 4.1.0、kombu 4.1.0、python 3.6
让我知道错误以及是否需要任何其他详细信息
【问题讨论】: