5

我正在尝试将 celery 3.1.0 与 Django 1.6 一起使用。我已经完成了本教程,但是一旦我使用它描述的方法(celery -A proj worker -l info)调用 celery,我会收到以下错误:

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__'

有没有人遇到过这个?我错过了什么?

4

3 回答 3

11

我通过将 celery 包绑定到适用于我的 django 应用程序的版本来修复此错误。

那些是引发错误的版本

celery # the newest 
celery==3.1 # main version before the newest

这是对我有用的版本

celery==3.1.25 # the last working version with my app
于 2016-11-17T11:14:38.700 回答
0

我用来celery==3.1.25解决问题

于 2018-02-16T15:21:04.560 回答
-1

芹菜 == 3.1 django == 1.10 django-celery == 3.1.17

这个版本不好用

于 2017-01-10T08:15:54.560 回答