Celery: Celery command not working in Django example

Created on 10 Mar 2016  路  1Comment  路  Source: celery/celery

Getting error while runing celery commad:

Celery command :

_celery -A proj worker -l info_

  File "/usr/bin/celery", line 9, in <module>
    load_entry_point('celery==3.1.6', 'console_scripts', 'celery')()
  File "/usr/lib/python2.7/dist-packages/celery/__main__.py", line 29, in main
    main()
  File "/usr/lib/python2.7/dist-packages/celery/bin/celery.py", line 80, in main
    cmd.execute_from_commandline(argv)
  File "/usr/lib/python2.7/dist-packages/celery/bin/celery.py", line 725, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/usr/lib/python2.7/dist-packages/celery/bin/base.py", line 298, in execute_from_commandline
    argv = self.setup_app_from_commandline(argv)
  File "/usr/lib/python2.7/dist-packages/celery/bin/base.py", line 428, in setup_app_from_commandline
    self.app = self.find_app(app)
  File "/usr/lib/python2.7/dist-packages/celery/bin/base.py", line 448, in find_app
    return find_app(app, symbol_by_name=self.symbol_by_name)
  File "/usr/lib/python2.7/dist-packages/celery/app/utils.py", line 222, in find_app
    sym = symbol_by_name(app, imp=imp)
  File "/usr/lib/python2.7/dist-packages/celery/bin/base.py", line 451, in symbol_by_name
    return symbol_by_name(name, imp=imp)
  File "/usr/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 90, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/usr/lib/python2.7/dist-packages/celery/utils/imports.py", line 101, in import_from_cwd
    return imp(module, package=package)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/vignesh/play/celery/examples/django/proj/__init__.py", line 5, in <module>
    from .celery import app as celery_app
  File "/home/vignesh/play/celery/examples/django/proj/celery.py", line 10, in <module>
    from django.conf import settings  # noqa
ImportError: No module named django.conf

Then I identified celery library was thers, So I installed celery with pip install celery and got the following error:

_**
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vignesh/play/celery/examples/django/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/vignesh/play/celery/examples/django/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/home/vignesh/play/celery/examples/django/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/home/vignesh/play/celery/examples/django/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/vignesh/play/celery/examples/django/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/vignesh/play/celery/examples/django/proj/__init__.py", line 5, in <module>
    from .celery import app as celery_app
  File "/home/vignesh/play/celery/examples/django/proj/celery.py", line 16, in <module>
    app.config_from_object('django.conf:settings', namespace='CELERY')
TypeError: config_from_object() got an unexpected keyword argument 'namespace'

Most helpful comment

The first error means Django was not installed, the second error means you are using the API of Celery 4.0 but running Celery 3.1

The namespace argument to config_from_object was introduced to the development version, it does not exist in Celery 3.1.

You should use the documentation from http://docs.celeryproject.org/en/latest for the stable release,
and the git branch https://github.com/celery/celery/tree/3.1 for the 3.1 series.

>All comments

The first error means Django was not installed, the second error means you are using the API of Celery 4.0 but running Celery 3.1

The namespace argument to config_from_object was introduced to the development version, it does not exist in Celery 3.1.

You should use the documentation from http://docs.celeryproject.org/en/latest for the stable release,
and the git branch https://github.com/celery/celery/tree/3.1 for the 3.1 series.

Was this page helpful?
0 / 5 - 0 ratings