Я получаю эту ошибку приложения Ошибка в Django Heroku КАК ее решить?

#python #django #heroku

Вопрос:

 my gunicorn :  web: gunicorn https://serene-atoll-07314.herokuapp.com/ --log-file -


2021-08-16T11:29:39.421911 00:00 heroku[web.1]: Starting process with command `gunicorn learning_logs.wsgi --log-file -`
2021-08-16T11:29:41.369052 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [4] [INFO] Starting gunicorn 20.1.0
2021-08-16T11:29:41.369655 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [4] [INFO] Listening at: http://0.0.0.0:41765 (4)
2021-08-16T11:29:41.369730 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [4] [INFO] Using worker: sync
2021-08-16T11:29:41.373634 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [9] [INFO] Booting worker with pid: 9
2021-08-16T11:29:41.377020 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [9] [ERROR] Exception in worker process
2021-08-16T11:29:41.377021 00:00 app[web.1]: Traceback (most recent call last):
2021-08-16T11:29:41.377022 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-08-16T11:29:41.377022 00:00 app[web.1]:     worker.init_process()
2021-08-16T11:29:41.377022 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-08-16T11:29:41.377022 00:00 app[web.1]:     self.load_wsgi()
2021-08-16T11:29:41.377023 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-08-16T11:29:41.377023 00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2021-08-16T11:29:41.377023 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-08-16T11:29:41.377024 00:00 app[web.1]:     self.callable = self.load()
2021-08-16T11:29:41.377024 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-08-16T11:29:41.377024 00:00 app[web.1]:     return self.load_wsgiapp()
2021-08-16T11:29:41.377024 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-08-16T11:29:41.377025 00:00 app[web.1]:     return util.import_app(self.app_uri)
2021-08-16T11:29:41.377025 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app
2021-08-16T11:29:41.377025 00:00 app[web.1]:     mod = importlib.import_module(module)
2021-08-16T11:29:41.377025 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2021-08-16T11:29:41.377025 00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2021-08-16T11:29:41.377026 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2021-08-16T11:29:41.377026 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2021-08-16T11:29:41.377026 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
2021-08-16T11:29:41.377026 00:00 app[web.1]: ModuleNotFoundError: No module named 'learning_logs.wsgi'
2021-08-16T11:29:41.377092 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [9] [INFO] Worker exiting (pid: 9)
2021-08-16T11:29:41.407065 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [4] [INFO] Shutting down: Master
2021-08-16T11:29:41.407153 00:00 app[web.1]: [2021-08-16 11:29:41  0000] [4] [INFO] Reason: Worker failed to boot.
2021-08-16T11:29:41.482746 00:00 heroku[web.1]: Process exited with status 3
2021-08-16T11:29:41.607641 00:00 heroku[web.1]: State changed from starting to crashed
2021-08-16T11:29:41.614239 00:00 heroku[web.1]: State changed from crashed to starting
2021-08-16T11:29:44.979775 00:00 heroku[web.1]: Starting process with command `gunicorn learning_logs.wsgi --log-file -`
2021-08-16T11:29:45.000000 00:00 app[api]: Build succeeded
2021-08-16T11:29:47.015811 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [4] [INFO] Starting gunicorn 20.1.0
2021-08-16T11:29:47.016196 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [4] [INFO] Listening at: http://0.0.0.0:41394 (4)
2021-08-16T11:29:47.016246 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [4] [INFO] Using worker: sync
2021-08-16T11:29:47.019350 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [9] [INFO] Booting worker with pid: 9
2021-08-16T11:29:47.022390 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [9] [ERROR] Exception in worker process
2021-08-16T11:29:47.022394 00:00 app[web.1]: Traceback (most recent call last):
2021-08-16T11:29:47.022396 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-08-16T11:29:47.022401 00:00 app[web.1]:     worker.init_process()
2021-08-16T11:29:47.022402 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-08-16T11:29:47.022402 00:00 app[web.1]:     self.load_wsgi()
2021-08-16T11:29:47.022403 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-08-16T11:29:47.022403 00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2021-08-16T11:29:47.022404 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-08-16T11:29:47.022404 00:00 app[web.1]:     self.callable = self.load()
2021-08-16T11:29:47.022404 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-08-16T11:29:47.022404 00:00 app[web.1]:     return self.load_wsgiapp()
2021-08-16T11:29:47.022405 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-08-16T11:29:47.022405 00:00 app[web.1]:     return util.import_app(self.app_uri)
2021-08-16T11:29:47.022405 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 359, in import_app
2021-08-16T11:29:47.022406 00:00 app[web.1]:     mod = importlib.import_module(module)
2021-08-16T11:29:47.022406 00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2021-08-16T11:29:47.022406 00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2021-08-16T11:29:47.022406 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2021-08-16T11:29:47.022407 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2021-08-16T11:29:47.022407 00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
2021-08-16T11:29:47.022407 00:00 app[web.1]: ModuleNotFoundError: No module named 'learning_logs.wsgi'
2021-08-16T11:29:47.022464 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [9] [INFO] Worker exiting (pid: 9)
2021-08-16T11:29:47.045340 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [4] [INFO] Shutting down: Master
2021-08-16T11:29:47.045372 00:00 app[web.1]: [2021-08-16 11:29:47  0000] [4] [INFO] Reason: Worker failed to boot.
2021-08-16T11:29:47.103003 00:00 heroku[web.1]: Process exited with status 3
2021-08-16T11:29:47.486086 00:00 heroku[web.1]: State changed from starting to crashed
 

Ответ №1:

Вам нужно будет проверить свою файловую структуру. В вашем каталоге learning_logs найдите файл wsgi.py который содержит следующий код (здесь я предполагаю, что ваш settings.py файл находится в файле learning_logs.settings):

 import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "learning_logs.settings")

application = get_wsgi_application()