Celery + Django错误:TypeError:'设置'对象不可订阅

时间:2015-09-13 12:29:45

标签: python django heroku celery

我遇到了这个问题,我完全不知道它来自哪里。

我使用与the Celery tutorial中提供的完全相同的代码,除了我使用项目目录作为我的唯一应用程序目录(因此,拥有models.py,views。 py并将' proj'添加到INSTALLED_APPS)。

奇怪的是,在我的本地计算机上尝试此设置时,每个django命令(migrate,shell ...)都会出现错误。删除virtualenv并重新安装大量修复它。现在,当将应用程序推送到Heroku时,我遇到了同样的问题并且无法使其运行。

任何提示? 谢谢!

ps:Python 3.4.2,Django 1.8.4,Celery 3.1.18

错误追溯:

Running `celery -A proj worker -l info` attached to terminal... up, run.7187
Traceback (most recent call last):
  File "/app/.heroku/python/bin/celery", line 9, in <module>
    load_entry_point('celery==3.1.0', 'console_scripts', 'celery')()
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/__main__.py", line 29, in main
    main()
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/celery.py", line 80, in main
    cmd.execute_from_commandline(argv)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/celery.py", line 732, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/base.py", line 299, in execute_from_commandline
    argv = self.setup_app_from_commandline(argv)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/base.py", line 429, in setup_app_from_commandline
    self.app = self.find_app(app)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/base.py", line 449, in find_app
    sym = self.symbol_by_name(app)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/bin/base.py", line 474, in symbol_by_name
    return symbol_by_name(name, imp=import_from_cwd)
  File "/app/.heroku/python/lib/python3.4/site-packages/kombu/utils/__init__.py", line 92, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
    return imp(module, package=package)
  File "/app/.heroku/python/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/app/proj/__init__.py", line 5, in <module>
    from .celery import app as celery_app
  File "/app/proj/celery.py", line 17, in <module>
    app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/app/base.py", line 277, in autodiscover_tasks
    if self.conf.CELERY_FORCE_BILLIARD_LOGGING:
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/datastructures.py", line 336, in __getattr__
    return self[k]
  File "/app/.heroku/python/lib/python3.4/site-packages/celery/datastructures.py", line 458, in __getitem__
    return d[key]
  File "/app/.heroku/python/lib/python3.4/site-packages/django/utils/functional.py", line 227, in inner
    return func(self._wrapped, *args)
TypeError: 'Settings' object is not subscriptable

1 个答案:

答案 0 :(得分:0)

您正在关注Celery 4.0的文档,但您使用的是Celery 3.1.18, 这会给你一个错误。

使用pip升级已安装的芹菜超过4.0。

pip install -U celery