celery-django 找不到设置
我有一个 Django 项目,它使用 Celery 来运行异步任务。我正在 Windows XP 计算机上进行开发。
启动我的 Django 服务器 (python manage.py runserver 80
) 工作正常,但尝试启动 Celery 守护进程 (python manage.py celeryd start
) 失败,并出现以下错误:
导入错误:无法导入设置“src.settings”(是否在 sys.path 上?是否有语法错误?):没有名为 src.settings 的模块
sys.path 包含“C:\development\” SpaceCorps\src',所以我不确定为什么它找不到这个模块。
这是启动守护进程的完整输出:
C:\development\SpaceCorps\src>python manage.py celeryd start
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mcelery@mike-laptop v2.0.1 is starting.?[0m
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mC:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\bin\celeryd.py:206: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in a production environment!
warnings.warn("Using settings.DEBUG leads to a memory leak, "?[0m
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mConfiguration ->
. broker -> amqp://guest@localhost:5672/
. queues ->
. celery -> exchange:celery (direct) binding:celery
. concurrency -> 2
. loader -> djcelery.loaders.DjangoLoader
. logfile -> [stderr]@WARNING
. events -> OFF
. beat -> OFF?[0m
[2010-07-23 18:29:31,706: WARNING/MainProcess] ?[1;33mcelery@mike-laptop has started.?[0m
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\Python26\lib\multiprocessing\forking.py", line 342, in main
self = load(from_parent)
File "C:\Program Files\Python26\lib\pickle.py", line 1370, in load
return Unpickler(file).load()
File "C:\Program Files\Python26\lib\pickle.py", line 858, in load
Traceback (most recent call last):
File "<string>", line 1, in <module>
dispatch[key](self)
File "C:\Program Files\Python26\lib\pickle.py", line 1090, in load_global
File "C:\Program Files\Python26\lib\multiprocessing\forking.py", line 342, in main
self = load(from_parent)
File "C:\Program Files\Python26\lib\pickle.py", line 1370, in load
klass = self.find_class(module, name)
File "C:\Program Files\Python26\lib\pickle.py", line 1124, in find_class
return Unpickler(file).load()
File "C:\Program Files\Python26\lib\pickle.py", line 858, in load
dispatch[key](self)
File "C:\Program Files\Python26\lib\pickle.py", line 1090, in load_global
__import__(module)
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\concurrency\processes\__init__.py", line 7, in <module>
from celery import log
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\log.py", line 8, in <module>
from celery import conf
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\conf.py", line 118, in <module>
ALWAYS_EAGER = _get("CELERY_ALWAYS_EAGER")
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\conf.py", line 109, in _get
value = getattr(settings, alias)
File "c:\development\django\django\utils\functional.py", line 276, in __getattr__
self._setup()
File "c:\development\django\django\conf\__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "c:\development\django\django\conf\__init__.py", line 75, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'src.settings' (Is it on sys.path? Does it have syntax errors?): No module named src.settings
I have a Django project that uses Celery for running asynchronous tasks. I'm doing my development on a Windows XP machine.
Starting my Django server (python manage.py runserver 80
) works fine, but attempting to start the Celery Daemon (python manage.py celeryd start
) fails with the following error:
ImportError: Could not import settings 'src.settings' (Is it on sys.path? Does it have syntax errors?): No module named src.settings
sys.path includes 'C:\development\SpaceCorps\src', so I'm not sure why it can't find this module.
Here's the full output from starting the daemon:
C:\development\SpaceCorps\src>python manage.py celeryd start
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mcelery@mike-laptop v2.0.1 is starting.?[0m
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mC:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\bin\celeryd.py:206: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in a production environment!
warnings.warn("Using settings.DEBUG leads to a memory leak, "?[0m
[2010-07-23 18:29:31,456: WARNING/MainProcess] ?[1;33mConfiguration ->
. broker -> amqp://guest@localhost:5672/
. queues ->
. celery -> exchange:celery (direct) binding:celery
. concurrency -> 2
. loader -> djcelery.loaders.DjangoLoader
. logfile -> [stderr]@WARNING
. events -> OFF
. beat -> OFF?[0m
[2010-07-23 18:29:31,706: WARNING/MainProcess] ?[1;33mcelery@mike-laptop has started.?[0m
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\Python26\lib\multiprocessing\forking.py", line 342, in main
self = load(from_parent)
File "C:\Program Files\Python26\lib\pickle.py", line 1370, in load
return Unpickler(file).load()
File "C:\Program Files\Python26\lib\pickle.py", line 858, in load
Traceback (most recent call last):
File "<string>", line 1, in <module>
dispatch[key](self)
File "C:\Program Files\Python26\lib\pickle.py", line 1090, in load_global
File "C:\Program Files\Python26\lib\multiprocessing\forking.py", line 342, in main
self = load(from_parent)
File "C:\Program Files\Python26\lib\pickle.py", line 1370, in load
klass = self.find_class(module, name)
File "C:\Program Files\Python26\lib\pickle.py", line 1124, in find_class
return Unpickler(file).load()
File "C:\Program Files\Python26\lib\pickle.py", line 858, in load
dispatch[key](self)
File "C:\Program Files\Python26\lib\pickle.py", line 1090, in load_global
__import__(module)
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\concurrency\processes\__init__.py", line 7, in <module>
from celery import log
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\log.py", line 8, in <module>
from celery import conf
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\conf.py", line 118, in <module>
ALWAYS_EAGER = _get("CELERY_ALWAYS_EAGER")
File "C:\Program Files\Python26\lib\site-packages\celery-2.0.1-py2.6.egg\celery\conf.py", line 109, in _get
value = getattr(settings, alias)
File "c:\development\django\django\utils\functional.py", line 276, in __getattr__
self._setup()
File "c:\development\django\django\conf\__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "c:\development\django\django\conf\__init__.py", line 75, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'src.settings' (Is it on sys.path? Does it have syntax errors?): No module named src.settings
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然这是 在 Windows 上运行 Celery。使用 --settings 参数 ala
python manage.py celeryd start --settings=settings
就达到了目的。Apparently this is a problem with running Celery on Windows. Using the --settings argument ala
python manage.py celeryd start --settings=settings
did the trick.sys.path 必须包含 'C:\development\SpaceCorps' 而不是 'C:\development\SpaceCorps\src',
因为他正在寻找 src.settings,而不仅仅是设置。
sys.path must include 'C:\development\SpaceCorps' not 'C:\development\SpaceCorps\src',
because he is looking for src.settings, not just settings.