Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.6 + Celery 3.1 = TypeError: 'Settings' object has no attribute '__getitem__'

Tags:

django

celery

I'm trying to use celery 3.1.0 with Django 1.6. I've gone through this tutorial but once I call celery using the method it describes (celery -A proj worker -l info) I get the following error:

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

Has anyone encountered this before? What am I missing?

like image 992
Dustin Avatar asked Nov 11 '13 17:11

Dustin


1 Answers

I fixed this error by binding my celery package to the version that works with my django application.

Those were the versions that throw the error

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

This is the version that worked for me

celery==3.1.25 # the last working version with my app
like image 144
Lukasz Dynowski Avatar answered Oct 16 '22 16:10

Lukasz Dynowski