[Answered ]-Import Error starting Celery worker

2👍

Found the problem. My Django project structure did not follow the default structure of-


--proj
|-- __init__.py
|-- settings.py
--accounts
|--__init__.py
--app2
|-- __init__.py

Instead if followed:

--proj
|-- __init__.py
|-- settings.py
|-- apps
|--accounts
|--__init__.py
|--app2
|-- __init__.py

which was causing Celery to find the module.

👤Devang

0👍

Also if you have such a structure you can ‘hack’ it this way:

sys.path.append(os.path.abspath('apps'))

before setting

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')

It worked for me. Of course you have to adjust the path in sys.path to your project structure.

Leave a comment