无法部署Django + Heroku at =错误代码= H10 desc =“应用程序崩溃”,方法= GET path =“ / favicon.ico”

问题描述

我在将第一个Django应用程序部署到Heroku时遇到问题。它在开发中效果很好,但我无法在日志中找到(或理解)该问题。我检查了多个具有相同H10错误的线程,但每个人似乎都有某种不同的日志,而他们的解决方案在我这一端不起作用。让我知道,除了以下内容之外,我是否还需要包含其他内容,以便了解发生了什么事情。

完整日志:

2020-08-11T08:36:47.390320+00:00 app[web.1]: self.callable = self.load()
2020-08-11T08:36:47.390320+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",line 49,in load
2020-08-11T08:36:47.390321+00:00 app[web.1]: return self.load_wsgiapp()
2020-08-11T08:36:47.390321+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",line 39,in load_wsgiapp
2020-08-11T08:36:47.390321+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-08-11T08:36:47.390321+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",line 358,in import_app
2020-08-11T08:36:47.390322+00:00 app[web.1]: mod = importlib.import_module(module)
2020-08-11T08:36:47.390322+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py",line 126,in import_module
2020-08-11T08:36:47.390322+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],package,level)
2020-08-11T08:36:47.390323+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 994,in _gcd_import
2020-08-11T08:36:47.390323+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 971,in _find_and_load
2020-08-11T08:36:47.390323+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 941,in _find_and_load_unlocked
2020-08-11T08:36:47.390324+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 219,in _call_with_frames_removed
2020-08-11T08:36:47.390324+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2020-08-11T08:36:47.390324+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2020-08-11T08:36:47.390325+00:00 app[web.1]: File "<frozen importlib._bootstrap>",line 953,in _find_and_load_unlocked
2020-08-11T08:36:47.390333+00:00 app[web.1]: ModuleNotFoundError: No module named 'craigslist_clone'
2020-08-11T08:36:47.390551+00:00 app[web.1]: [2020-08-11 08:36:47 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-08-11T08:36:47.442506+00:00 app[web.1]: [2020-08-11 08:36:47 +0000] [4] [INFO] Shutting down: Master
2020-08-11T08:36:47.442581+00:00 app[web.1]: [2020-08-11 08:36:47 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-08-11T08:36:47.540045+00:00 heroku[web.1]: Process exited with status 3
2020-08-11T08:36:47.589027+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-11T08:36:47.591726+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-11T08:36:52.986845+00:00 heroku[web.1]: Starting process with command `gunicorn craigslist_clone.wsgi`
2020-08-11T08:36:54.949245+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-08-11T08:36:54.949773+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [4] [INFO] Listening at: http://0.0.0.0:44861 (4)
2020-08-11T08:36:54.949871+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [4] [INFO] Using worker: sync
2020-08-11T08:36:54.954399+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [10] [INFO] Booting worker with pid: 10
2020-08-11T08:36:54.960530+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [10] [ERROR] Exception in worker process
2020-08-11T08:36:54.960531+00:00 app[web.1]: Traceback (most recent call last):
2020-08-11T08:36:54.960531+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",line 583,in spawn_worker
2020-08-11T08:36:54.960531+00:00 app[web.1]: worker.init_process()
2020-08-11T08:36:54.960532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",line 119,in init_process
2020-08-11T08:36:54.960532+00:00 app[web.1]: self.load_wsgi()
2020-08-11T08:36:54.960532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",line 144,in load_wsgi
2020-08-11T08:36:54.960532+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-08-11T08:36:54.960533+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",line 67,in wsgi
2020-08-11T08:36:54.960533+00:00 app[web.1]: self.callable = self.load()
2020-08-11T08:36:54.960533+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load
2020-08-11T08:36:54.960533+00:00 app[web.1]: return self.load_wsgiapp()
2020-08-11T08:36:54.960534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load_wsgiapp
2020-08-11T08:36:54.960534+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-08-11T08:36:54.960534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",in import_app
2020-08-11T08:36:54.960534+00:00 app[web.1]: mod = importlib.import_module(module)
2020-08-11T08:36:54.960534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py",in import_module
2020-08-11T08:36:54.960535+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],level)
2020-08-11T08:36:54.960535+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2020-08-11T08:36:54.960535+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2020-08-11T08:36:54.960535+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2020-08-11T08:36:54.960536+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _call_with_frames_removed
2020-08-11T08:36:54.960536+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2020-08-11T08:36:54.960536+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2020-08-11T08:36:54.960536+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2020-08-11T08:36:54.960540+00:00 app[web.1]: ModuleNotFoundError: No module named 'craigslist_clone'
2020-08-11T08:36:54.960717+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-08-11T08:36:54.981960+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [11] [INFO] Booting worker with pid: 11
2020-08-11T08:36:54.987590+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [11] [ERROR] Exception in worker process
2020-08-11T08:36:54.987592+00:00 app[web.1]: Traceback (most recent call last):
2020-08-11T08:36:54.987592+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py",in spawn_worker
2020-08-11T08:36:54.987593+00:00 app[web.1]: worker.init_process()
2020-08-11T08:36:54.987593+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",in init_process
2020-08-11T08:36:54.987594+00:00 app[web.1]: self.load_wsgi()
2020-08-11T08:36:54.987594+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py",in load_wsgi
2020-08-11T08:36:54.987594+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-08-11T08:36:54.987595+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py",in wsgi
2020-08-11T08:36:54.987595+00:00 app[web.1]: self.callable = self.load()
2020-08-11T08:36:54.987600+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load
2020-08-11T08:36:54.987600+00:00 app[web.1]: return self.load_wsgiapp()
2020-08-11T08:36:54.987600+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",in load_wsgiapp
2020-08-11T08:36:54.987601+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-08-11T08:36:54.987601+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py",in import_app
2020-08-11T08:36:54.987602+00:00 app[web.1]: mod = importlib.import_module(module)
2020-08-11T08:36:54.987602+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py",in import_module
2020-08-11T08:36:54.987602+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:],level)
2020-08-11T08:36:54.987603+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2020-08-11T08:36:54.987603+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2020-08-11T08:36:54.987604+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2020-08-11T08:36:54.987604+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _call_with_frames_removed
2020-08-11T08:36:54.987605+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _gcd_import
2020-08-11T08:36:54.987605+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load
2020-08-11T08:36:54.987605+00:00 app[web.1]: File "<frozen importlib._bootstrap>",in _find_and_load_unlocked
2020-08-11T08:36:54.987611+00:00 app[web.1]: ModuleNotFoundError: No module named 'craigslist_clone'
2020-08-11T08:36:54.987736+00:00 app[web.1]: [2020-08-11 08:36:54 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-08-11T08:36:55.000000+00:00 app[api]: Build succeeded
2020-08-11T08:36:55.093662+00:00 app[web.1]: [2020-08-11 08:36:55 +0000] [4] [INFO] Shutting down: Master
2020-08-11T08:36:55.093752+00:00 app[web.1]: [2020-08-11 08:36:55 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-08-11T08:36:55.157659+00:00 heroku[web.1]: Process exited with status 3
2020-08-11T08:36:55.193966+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-11T08:37:07.657451+00:00 app[api]: Starting process with command `python manage.py migrate` by user mwoonky@gmail.com
2020-08-11T08:37:13.678634+00:00 heroku[run.6426]: State changed from starting to up
2020-08-11T08:37:13.774667+00:00 heroku[run.6426]: Awaiting client
2020-08-11T08:37:13.797319+00:00 heroku[run.6426]: Starting process with command `python manage.py migrate`
2020-08-11T08:37:20.153983+00:00 heroku[run.6426]: Process exited with status 0
2020-08-11T08:37:20.189249+00:00 heroku[run.6426]: State changed from up to complete
2020-08-11T08:37:26.966717+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-journey-70264.herokuapp.com request_id=f71ce6d3-dd74-4a25-8468-289bcda1f39f fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https
2020-08-11T08:37:28.566366+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-journey-70264.herokuapp.com request_id=dda4b09d-62cd-4cce-a613-181aa9a49d00 fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https
2020-08-11T08:38:20.797118+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-journey-70264.herokuapp.com request_id=9fe9cfbe-ee30-41fe-83c8-34ce82b577b6 fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https
2020-08-11T08:38:22.379610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-journey-70264.herokuapp.com request_id=b6ab19f3-131b-451f-83f0-a4f7149b39a6 fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https
2020-08-11T08:39:14.019669+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-journey-70264.herokuapp.com request_id=f75b7237-4cef-4546-ada6-4c604be042eb fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https
2020-08-11T08:39:15.505950+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-journey-70264.herokuapp.com request_id=3e03d12f-8b60-4777-85fb-4a67fe3ccc4a fwd="145.101.22.108" dyno= connect= service= status=503 bytes= protocol=https

Procfile

web: gunicorn craigslist_clone.wsgi

这是我的要求。txt

appdirs==1.4.4
asgiref==3.2.10
beautifulsoup4==4.9.1
bs4==0.0.1
certifi==2020.6.20
chardet==3.0.4
distlib==0.3.1
dj-database-url==0.5.0
Django==3.1
django-heroku==0.3.1
filelock==3.0.12
gunicorn==20.0.4
heroku==0.1.4
idna==2.10
pipenv==2020.6.2
psycopg2==2.8.5
psycopg2-binary==2.8.5
python-dateutil==1.5
pytz==2020.1
requests==2.24.0
six==1.15.0
soupsieve==2.0.1
sqlparse==0.3.1
urllib3==1.25.10
virtualenv==20.0.30
virtualenv-clone==0.5.4
whitenoise==5.2.0

Settings.py还包括以下内容:

import django_heroku
django_heroku.settings(locals())

解决方法

ModuleNotFoundError:没有名为“ craigslist_clone”的模块

如果craigslist_clone是您的本地函数,请检查函数调用,或者如果craigslist_clone是全局python函数,则找不到craigslist_clone

如果共享代码文件存在问题

,

错误:发生什么错误表示没有模块'craigslist_clone'

正如您提到的,它在开发中效果很好,并且在部署中发生错误。因此错误不是来自任何python函数。

我建议您在requirements.txt文件中指定显式依赖项版本。要更新此文件,可以在活动的虚拟环境(开发)中使用pip freeze命令:

$ pip freeze > requirements.txt

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...