Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery + Django error: TypeError: 'Settings' object is not subscriptable

I'm running into this issue and I have absolutely no idea where it comes from.

I'm using exactly the same code provided in the Celery tutorial except for the fact that I'm using the project directory also as my unique app directory (so, having models.py, views.py and adding 'proj' to INSTALLED_APPS).

The weird part is, while trying this setup on my local machine, the error always appeared with every django command (migrate, shell...). Removing the virtualenv and reinstalling misteriously fixed it. Now, when pushing the app to Heroku I'm having the same issue and can't make it work.

Any hints? Thanks!

ps: Python 3.4.2, Django 1.8.4, Celery 3.1.18


The error traceback:

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
like image 588
Eric Marcos Avatar asked Sep 13 '15 12:09

Eric Marcos


Video Answer


1 Answers

You're following Celery 4.0's document, but you're using Celery 3.1.18, This gives you an error.

Upgrade your installed celery over than 4.0 with pip.

pip install -U celery

like image 114
Beomi Avatar answered Oct 25 '22 15:10

Beomi