I'm following the starting with Django for Celery tutorial. pip installed everything in the virtualenv (activated)
and have the following structure:
project folder/
dev.db
manage.py
app.one/ #app folder
celeryapp # a folder that contains the files from the tutorial.
/__init__.py
/celery.py #as explained in the tutorial
projectname/ #folder that contains settings.py, urls etc.
My problem, after installing djcelery
and adding it to django INSTALLED_APPS
, everything that touches django runserver fails with:
ImportError: Could not import settings 'register.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named celery
using 3.1.6
the celery.py is as follows:
#!/usr/bin/env/python
from __future__ import absolute_import
import os
from celery import Celery
from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE','register.settings')
app = Celery('celery')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
@app.task(bind = True)
def debug_task(self):
print ('Request: {0!r} '.format(self.request))
Any ideas? links? how can solve this problem..
Thanks for the help
I think your celery.py module is shadowing the real celery library.
In the tutorial they have their celery.py in "proj/proj/celery.py" and are using:
from __future__ import absolute_import
To make sure that they don't end up re-importing the same file again.
You basically need to move your celery.py somewhere else (eg inside projectname I think).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.