我有一个 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/