在heroku示例上找不到djangocelery 的模块

cyej8jka  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(414)

我和一个redis经纪人在django做了celery 。这一切在本地运行得很好,但当我在部署heroku示例后记录该示例时,出现以下错误:

ModuleNotFoundError: No module named 'app'

这是我的celery .py,它位于我的项目文件夹project/project/celery .py的根目录中:

import os
from celery import Celery

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AutomatedInterview.settings")
app = Celery("AutomatedInterview")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()

同一目录中的my init.py:

from __future__ import absolute_import, unicode_literals

# This will make sure the app is always imported when

# Django starts so that shared_task will use this app.

from .celery import app as celery_app

__all__ = ('celery_app',)

我的文件:

release: python manage.py migrate
web: gunicorn AutomatedInterview.wsgi
worker: celery worker -A AutomatedInterview -l info

运行命令后的完整日志 heroku logs -t -p worker ```
2020-06-18T19:11:38.697329+00:00 app[worker.1]: Traceback (most recent call last):
2020-06-18T19:11:38.697361+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/kombu/utils/objects.py", line 42, in get
2020-06-18T19:11:38.697485+00:00 app[worker.1]: return obj.dict[self.name]
2020-06-18T19:11:38.697488+00:00 app[worker.1]: KeyError: 'data'
2020-06-18T19:11:38.697509+00:00 app[worker.1]:
2020-06-18T19:11:38.697509+00:00 app[worker.1]: During handling of the above exception, another exception occurred:
2020-06-18T19:11:38.697510+00:00 app[worker.1]:
2020-06-18T19:11:38.697510+00:00 app[worker.1]: Traceback (most recent call last):
2020-06-18T19:11:38.697513+00:00 app[worker.1]: File "/app/.heroku/python/bin/celery", line 11, in
2020-06-18T19:11:38.697621+00:00 app[worker.1]: sys.exit(main())
2020-06-18T19:11:38.697624+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/main.py", line 16, in main
2020-06-18T19:11:38.697747+00:00 app[worker.1]: _main()
2020-06-18T19:11:38.697749+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 322, in main
2020-06-18T19:11:38.697990+00:00 app[worker.1]: cmd.execute_from_commandline(argv)
2020-06-18T19:11:38.697992+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 495, in execute_from_commandline
2020-06-18T19:11:38.698486+00:00 app[worker.1]: super(CeleryCommand, self).execute_from_commandline(argv)))
2020-06-18T19:11:38.698491+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 305, in execute_from_commandline
2020-06-18T19:11:38.698741+00:00 app[worker.1]: return self.handle_argv(self.prog_name, argv[1:])
2020-06-18T19:11:38.698747+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 487, in handle_argv
2020-06-18T19:11:38.699125+00:00 app[worker.1]: return self.execute(command, argv)
2020-06-18T19:11:38.699130+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 419, in execute
2020-06-18T19:11:38.699591+00:00 app[worker.1]: ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
2020-06-18T19:11:38.699596+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/worker.py", line 221, in run_from_argv
2020-06-18T19:11:38.699918+00:00 app[worker.1]: *self.parse_options(prog_name, argv, command))
2020-06-18T19:11:38.699953+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 428, in parse_options
2020-06-18T19:11:38.700336+00:00 app[worker.1]: self.parser = self.create_parser(prog_name, command)
2020-06-18T19:11:38.700369+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 444, in create_parser
2020-06-18T19:11:38.700796+00:00 app[worker.1]: self.add_arguments(parser)
2020-06-18T19:11:38.700830+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/worker.py", line 278, in add_arguments
2020-06-18T19:11:38.701211+00:00 app[worker.1]: default=conf.worker_state_db,
2020-06-18T19:11:38.701244+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/utils/collections.py", line 134, in getattr
2020-06-18T19:11:38.701471+00:00 app[worker.1]: return self[k]
2020-06-18T19:11:38.701503+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/utils/collections.py", line 444, in getitem
2020-06-18T19:11:38.701893+00:00 app[worker.1]: return getitem(k)
2020-06-18T19:11:38.701925+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/utils/collections.py", line 287, in getitem
2020-06-18T19:11:38.702238+00:00 app[worker.1]: return mapping[_key]
2020-06-18T19:11:38.702270+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/collections/init.py", line 987, in getitem
2020-06-18T19:11:38.703011+00:00 app[worker.1]: if key in self.data:
2020-06-18T19:11:38.703043+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/kombu/utils/objects.py", line 44, in get
2020-06-18T19:11:38.703212+00:00 app[worker.1]: value = obj.dict[self.name] = self.__get(obj)
2020-06-18T19:11:38.703243+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/app/base.py", line 141, in data
2020-06-18T19:11:38.703468+00:00 app[worker.1]: return self.callback()
2020-06-18T19:11:38.703499+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/app/base.py", line 954, in _finalize_pending_conf
2020-06-18T19:11:38.704209+00:00 app[worker.1]: conf = self._conf = self._load_config()
2020-06-18T19:11:38.704242+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/app/base.py", line 964, in _load_config
2020-06-18T19:11:38.704992+00:00 app[worker.1]: self.loader.config_from_object(self._config_source)
2020-06-18T19:11:38.705025+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/loaders/base.py", line 131, in config_from_object
2020-06-18T19:11:38.705245+00:00 app[worker.1]: self._conf = force_mapping(obj)
2020-06-18T19:11:38.705290+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/utils/collections.py", line 54, in force_mapping
2020-06-18T19:11:38.705460+00:00 app[worker.1]: if isinstance(m, (LazyObject, LazySettings)):
2020-06-18T19:11:38.705477+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/functional.py", line 256, in inner
2020-06-18T19:11:38.705764+00:00 app[worker.1]: self._setup()
2020-06-18T19:11:38.705782+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/init.py", line 66, in _setup
2020-06-18T19:11:38.705957+00:00 app[worker.1]: self._wrapped = Settings(settings_module)
2020-06-18T19:11:38.705974+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/init.py", line 157, in init
2020-06-18T19:11:38.706227+00:00 app[worker.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2020-06-18T19:11:38.706228+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/importlib/init.py", line 126, in import_module
2020-06-18T19:11:38.706425+00:00 app[worker.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-06-18T19:11:38.706429+00:00 app[worker.1]: File "", line 994, in _gcd_import
2020-06-18T19:11:38.706584+00:00 app[worker.1]: File "", line 971, in _find_and_load
2020-06-18T19:11:38.706679+00:00 app[worker.1]: File "", line 941, in _find_and_load_unlocked
2020-06-18T19:11:38.706773+00:00 app[worker.1]: File "", line 219, in _call_with_frames_removed
2020-06-18T19:11:38.706864+00:00 app[worker.1]: File "", line 994, in _gcd_import
2020-06-18T19:11:38.706965+00:00 app[worker.1]: File "", line 971, in _find_and_load
2020-06-18T19:11:38.707055+00:00 app[worker.1]: File "", line 953, in _find_and_load_unlocked
2020-06-18T19:11:38.707154+00:00 app[worker.1]: ModuleNotFoundError: No module named 'app'

我真的不知道这个模块指的是什么,也不知道它是从哪里来的。我 `app` 在celery 中使用。py直接从文档中删除。
有什么特别的吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题