【问题标题】:Unable to start Celery on OS X Mavericks无法在 OS X Mavericks 上启动 Celery
【发布时间】:2015-06-04 04:14:29
【问题描述】:

我想在运行 OS X 10.9.5 的 Mac 上开发的 Django 1.6.2 应用程序中使用 Celery 和 Redis。首先,我正在研究First Steps with Celery 文档。但是,当我尝试使用此命令按照文档中所示启动 Celery 时:

celery -A tasks worker --loglevel=info

我收到此错误:

[<date>: ERROR/MainProcess] consumer: Cannot connect to redis://127.0.0.1:6379//: Error 61 connecting to 127.0.0.1:6379. Connection refused..  Trying again in 2.00 seconds...

从我的研究来看,问题可能是因为我没有启动 Redis 服务器而出现的。当我查看我的进程时,我看不到它正在运行。但是,Celery 文档没有讨论启动服务器,我在虚拟环境的 redis 分支中的任何地方都没有看到“redis-server”命令。

我用这个命令安装了redis:

pip install -U celery[redis]

然后我将 /usr/lib 添加到我的 DYLD_FALLBACK_LIBRARY_PATH 环境变量中。

我还在我的 Django 设置中添加了以下行:

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

我尝试运行的 Python 脚本是文档中显示的示例:

# tasks.py
from celery import Celery

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

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

我尝试使用“localhost”而不是“127.0.0.1”,但这并没有解决问题。我做错了什么?

谢谢!

【问题讨论】:

  • 嗯...看起来像执行“pip install celery[redis]”并没有安装 Redis,只是 Celery 需要与之对话的绑定。我现在正在调查。
  • 是的,我需要安装 Redis。对不起,伙计们,这个愚蠢的问题。

标签: django redis celery


【解决方案1】:

是的,问题是我实际上并没有安装 Redis。这两篇文章很有帮助:

Compiling a Web Development Environment on Mac OS X
How to install redis on OS X

【讨论】:

    猜你喜欢
    • 2013-11-03
    • 1970-01-01
    • 2014-04-18
    • 2013-11-01
    • 1970-01-01
    • 2014-08-15
    • 2014-02-12
    • 2023-04-04
    • 2014-09-02
    相关资源
    最近更新 更多