Categories
Development

Django: ImportError: cannot import name ‘Celery’ from ‘celery’

So I’ve installed celery and got the file celery_tasks_settings.py in my project directory next to settings.py. This I got was a way to avoid conflicts with the package itself.

I also did

find -name '*celery*.pyc'

as a way to find any celery.pyc files that may have been generated before.The result:

/__pycache__/celery_tasks.cpython-38.pyc
/__pycache__/celery_tasks_settings.cpython-38.pyc

Unfortunately, I still get the same error:

   from celery import Celery
ImportError: cannot import name 'Celery' from 'celery' 

Am I doing something wrong?

PS: I also went ahead and tried adding:

from __future__ import absolute_import, unicode_literals

to my celery_tasks_settings.py

My error still won’t budge.
[EDIT]
Full traceback

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/core/management/base.py", line 336, in run_from_argv
    connections.close_all()
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/db/utils.py", line 219, in close_all
    for alias in self:
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/db/utils.py", line 213, in __iter__
    return iter(self.databases)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/utils/functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/db/utils.py", line 147, in databases
    self._databases = settings.DATABASES
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/HotelManagement/__init__.py", line 4, in <module>
    from .celery_tasks_settings import app as celery_app
  File "/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/HotelManagement/celery_tasks_settings.py", line 4, in <module>
    from celery import Celery
ImportError: cannot import name 'Celery' from 'celery' (/run/media/marvin/DriveEtCetera/Python/MyProjectsDirectory/super-lamp/.superlamp/lib/python3.8/site-packages/celery/__init__.py)

Leave a Reply

Your email address will not be published. Required fields are marked *