我正在学习starting with Django for Celery教程。pip安装了virtualenv中的所有内容(已激活)
并具有以下结构:
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.我的问题是,在安装djcelery并将其添加到django INSTALLED_APPS之后,所有涉及django runserver的东西都失败了,错误代码是:
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使用3.1.6
celery.py如下:
#!/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))有什么想法吗?链接?怎样才能解决这个问题。
谢谢你的帮助
发布于 2015-05-14 18:29:51
我认为你的celery.py模块在遮蔽真正的芹菜库。
在本教程中,他们将自己的celery.py放在"proj/proj/celery.py“中,并使用:
from __future__ import absolute_import以确保它们最终不会再次导入相同的文件。
你基本上需要把你的celery.py移到其他地方(例如,我想是在项目名里面)。
https://stackoverflow.com/questions/20387053
复制相似问题