2

I'm getting this error after running the following command:

C:\Users\callu\project_name>celery -A project_name worker -l info

I'm wondering if it has something to do with the fact that I've not created my django project in a virtual environment but I can't find anything on the issue. If it was due to it being outside a virtual environment I'm not sure how I'd get around it without restarting the project in one (is it easy to move to a venv in PyCharm?)

I run my django server and my above celery command here:

C:\Users\callu\project_name>

I run start my RabbitMQ server in another location (not venv) but don't think that's the issue

Full Traceback:

Traceback (most recent call last):
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 70, in __get__
    return obj_dict[name]
KeyError: 'data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\Scripts\celery.exe\__main__.py", line 7, in <module>
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\__main__.py", line 15, in main
    sys.exit(_main())
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\celery.py", line 213, in main
    return celery(auto_envvar_prefix="CELERY")
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1135, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 641, in make_context
    self.parse_args(ctx, args)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 940, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1477, in handle_parse_result
    self.callback, ctx, self, value)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 96, in invoke_param_callback
    return callback(ctx, param, value)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\worker.py", line 156, in <lambda>
    value: value or ctx.obj.app.conf.worker_state_db,
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 111, in __getattr__
    return self[k]
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 391, in __getitem__
    return getitem(k)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 249, in __getitem__
    return mapping[_key]
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\collections\__init__.py", line 1021, in __getitem__
    if key in self.data:
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\objects.py", line 29, in __get__
    return super().__get__(instance, owner)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 74, in __get__
    return obj_dict.setdefault(name, self.func(obj))
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 138, in data
    return self.callback()
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 946, in _finalize_pending_conf
    conf = self._conf = self._load_config()
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 956, in _load_config
    self.loader.config_from_object(self._config_source)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 123, in config_from_object
    obj = self._smart_import(obj, imp=self.import_from_cwd)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 136, in _smart_import
    return symbol_by_name(path, imp=imp)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\imports.py", line 56, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 95, in import_from_cwd
    package=package,
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\imports.py", line 100, in import_from_cwd
    return imp(module, package=package)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 89, in import_module
    return importlib.import_module(module, package=package)
  File "c:\users\callu\appdata\local\programs\python\python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django.config'

5
  • Where is django.config from? (And in case you missed it, that's not the original exception.) Commented Oct 23, 2021 at 9:27
  • Ah I didn't realise that wasn't the first exception, sadly that exception isn't very descriptive, an error with a dictionary in the cached_property.py file? django.cofig is in my celery.py file here app.config_from_object('django.config:settings', namespace='CELERY'). At least that's where I think it's coming from. Commented Oct 23, 2021 at 14:00
  • 1
    Perhaps you meant 'django.conf:settings'? Commented Oct 23, 2021 at 14:02
  • Yes! So simple, can't believe I kept missing that, thanks for the help Commented Oct 23, 2021 at 16:16
  • Could you reproduce the exception with cached_property? What's Scripts\celery.exe\__main__.py", line 7? Commented Oct 23, 2021 at 16:23

1 Answer 1

2
+50

It sounds like you have somewhere (in your app/celery.py if using the standard layout) a line that looks like:

app.config_from_object('django.config:settings', namespace='CELERY')

where app is your Celery app object.

But what you need is:

app.config_from_object('django.conf:settings', namespace='CELERY')

Note: you the django config module is django.conf not django.config.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.