python - celery 使用错误的 python 版本

标签 python django celery

我有一个 Django 项目,我想使用 Celery。我已经为 python3 安装了 Celery,然后我运行这个命令:sudo celery -A myApp worker -l info

但是在日志中,我看到使用的是 python2.7 的 Celery :File "/Library/Python/2.7/site-packages

知道如何使用为 python3 安装的 Celery 吗?

最佳答案

好的,感谢@Wayne,我找到了解决方案。

首先,使用此命令查看 celery 的头部位置:head -n 10/usr/local/bin/celery 对于我自己,这就是我得到的:

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'celery==3.1.23','console_scripts','celery'
__requires__ = 'celery==3.1.23'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('celery==3.1.23', 'console_scripts', 'celery')()
    )

我看到第一个 shebang (#!/usr/bin/python) 使用了错误的 python 版本。

然后,我更改了第一个 shebang:#!/usr/bin/env python3 并保存文件。现在 celery 指向 python3。

关于python - celery 使用错误的 python 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37911169/

相关文章:

python - RabbitMQ IOError : Socket closed

python - 如何为动态 URL 列表创建 Locust 任务?

django - 在 Nuxt Auth 中设置 session ID Cookie

python - 从数据库中断中恢复 Celery

python - 如何配置和运行 celerybeat

css - Django 模板继承——标记 CSS 类

python - 将数据帧上传到bigquery时,日期类型的对象不是JSON可序列化错误?

python - API 可以告诉 Pylint 不要在客户端代码中提示吗?

Python:连接字符串并在它们之间插入字符串的最简单方法?

python - 从 Django 模型中过滤外键 ID