我正在尝试将芹菜 3.1.0 与 Django 1.6 一起使用。我已经完成了本教程,但是一旦我使用它描述的方法调用芹菜(celery -A proj worker -l info
),我就会收到以下错误:
Traceback (most recent call last):
File "/Users/dustin/.virtualenvs/proj_env/bin/celery", line 9, in <module>
load_entry_point('celery==3.1.0', 'console_scripts', 'celery')()
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/__main__.py", line 29, in main
main()
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/celery.py", line 80, in main
cmd.execute_from_commandline(argv)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/celery.py", line 732, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/base.py", line 299, in execute_from_commandline
argv = self.setup_app_from_commandline(argv)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/base.py", line 429, in setup_app_from_commandline
self.app = self.find_app(app)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/base.py", line 463, in find_app
'{0}.celery:'.format(app.replace(':', '')),
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/base.py", line 449, in find_app
sym = self.symbol_by_name(app)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/bin/base.py", line 474, in symbol_by_name
return symbol_by_name(name, imp=import_from_cwd)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/kombu/utils/__init__.py", line 90, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
return imp(module, package=package)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/dustin/src/myco/proj/proj/celery.py", line 13, in <module>
app.autodiscover_tasks(settings.INSTALLED_APPS, related_name='tasks')
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/app/base.py", line 277, in autodiscover_tasks
if self.conf.CELERY_FORCE_BILLIARD_LOGGING:
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/datastructures.py", line 336, in __getattr__
return self[k]
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/celery/datastructures.py", line 458, in __getitem__
return d[key]
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/django/utils/functional.py", line 214, in inner
return func(self._wrapped, *args)
File "/Users/dustin/.virtualenvs/proj_env/lib/python2.7/site-packages/django/utils/functional.py", line 263, in __getitem__
return self[key]
TypeError: 'Settings' object has no attribute '__getitem__'
以前有人遇到过这种情况吗?我错过了什么?
我通过将我的芹菜包绑定到适用于我的 django 应用程序的版本来修复此错误。
这些是引发错误的版本
celery # the newest
celery==3.1 # main version before the newest
这是对我有用的版本
celery==3.1.25 # the last working version with my app
我用celery==3.1.25
来解决问题
芹菜 == 3.1 姜戈 ==1.10 姜戈-芹菜 == 3.1.17
此版本不能很好地工作