我使用django v1.7.0b4和芹菜v3.1.1。按照django安装指南中的步骤进行操作。但是我被下面的错误卡住了。
$ ./manage.py celeryd --help
Starting server in DEVELOPMENT Mode
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 427, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django_celery-3.1.10-py2.7.egg/djcelery/management/base.py", line 77, in run_from_argv
return super(CeleryCommand, self).run_from_argv(argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 284, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 265, in create_parser
option_list=self.option_list)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1214, in __init__
add_help=add_help_option)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1256, in _populate_option_list
self.add_options(option_list)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1039, in add_options
self.add_option(option)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1020, in add_option
self._check_conflict(option)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 995, in _check_conflict
option)
optparse.OptionConflictError: option -C/--no-color: conflicting option string(s): --no-color
还有其他人面临同样的问题吗?
编辑:
您应该使用./manage.py celery worker
而不是./manage.py celeryd
当你使用:
时,看起来有一个bugdjango==1.7b4
celery==3.1.11
django-celery==3.1.10
帮助你避免这些问题的几个技巧:
- 当你开始玩一个项目时,远离测试版,使用稳定版。
- 不要使用已弃用的方法:
./manage.py celeryd
是./manage celery worker
的旧别名
django-芹菜的不兼容性已在两个月前修复:https://github.com/celery/django-celery/pull/320。如果您正在使用virtualenv,那么您可以像这样进行猴子补丁:
sed "s/(= ['--app', '--loader', '--config')]/1, '--no-color']/" -i
"$VIRTUAL_ENV/lib/python3.4/site-packages/djcelery/management/base.py"
用芹菜3.1.13和django-芹菜3.1.10测试