I have developed a flask application. It was working fine. I tried to deploy on the Heroku platform, it was built good but it has an application error as below:
2021-05-20T09:38:34.964141+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-20T09:38:40.032215+00:00 heroku[web.1]: Starting process with command `gunicorn wsgi:app`
2021-05-20T09:38:42.826792+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-05-20T09:38:42.830037+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [4] [INFO] Listening at: http://0.0.0.0:50352 (4)
2021-05-20T09:38:42.830128+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [4] [INFO] Using worker: sync
2021-05-20T09:38:42.836063+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [8] [INFO] Booting worker with pid: 8
2021-05-20T09:38:42.843087+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [8] [ERROR] Exception in worker process
2021-05-20T09:38:42.843089+00:00 app[web.1]: Traceback (most recent call last):
2021-05-20T09:38:42.843089+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-05-20T09:38:42.843090+00:00 app[web.1]: worker.init_process()
2021-05-20T09:38:42.843090+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-05-20T09:38:42.843091+00:00 app[web.1]: self.load_wsgi()
2021-05-20T09:38:42.843091+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-05-20T09:38:42.843092+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-05-20T09:38:42.843092+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-05-20T09:38:42.843092+00:00 app[web.1]: self.callable = self.load()
2021-05-20T09:38:42.843093+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-05-20T09:38:42.843093+00:00 app[web.1]: return self.load_wsgiapp()
2021-05-20T09:38:42.843094+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-05-20T09:38:42.843094+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-05-20T09:38:42.843094+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
2021-05-20T09:38:42.843095+00:00 app[web.1]: mod = importlib.import_module(module)
2021-05-20T09:38:42.843095+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-05-20T09:38:42.843096+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-05-20T09:38:42.843096+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-05-20T09:38:42.843097+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-05-20T09:38:42.843097+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-05-20T09:38:42.843097+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-05-20T09:38:42.843098+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 848, in exec_module
2021-05-20T09:38:42.843098+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-05-20T09:38:42.843098+00:00 app[web.1]: File "/app/wsgi.py", line 1, in <module>
2021-05-20T09:38:42.843099+00:00 app[web.1]: from flaskr import create_app
2021-05-20T09:38:42.843099+00:00 app[web.1]: File "/app/flaskr/__init__.py", line 2, in <module>
2021-05-20T09:38:42.843099+00:00 app[web.1]: from flask import Flask
2021-05-20T09:38:42.843100+00:00 app[web.1]: ModuleNotFoundError: No module named 'flask'
2021-05-20T09:38:42.843265+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-05-20T09:38:42.886561+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [4] [INFO] Shutting down: Master
2021-05-20T09:38:42.886676+00:00 app[web.1]: [2021-05-20 09:38:42 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-05-20T09:38:42.970279+00:00 heroku[web.1]: Process exited with status 3
2021-05-20T09:38:43.061569+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-20T09:40:29.210283+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fierce-chamber-66326.herokuapp.com request_id=280feef6-db16-418e-a698-118e3d93c830 fwd="223.227.29.80" dyno= connect= service= status=503 bytes= protocol=https
It shows as the flask module is not installed. Even though I have listed the flask in the requirements.txt.
I checked if it is actually installed by running heroku run pip freeze
command, it did not show the flask as installed. The output of the heroku run pip freeze is as below:
Running pip freeze on ⬢ fierce-chamber-66326... up, run.8204 (Free)
appdirs==1.4.4
certifi==2020.12.5
distlib==0.3.1
filelock==3.0.12
gunicorn==20.1.0
pipenv==2020.11.15
six==1.16.0
virtualenv==20.4.6
virtualenv-clone==0.5.4
I am attaching my repo link here, Can anyone check it and find where the error is?
Edit : Below is a part of my Requirements.txt
colorama==0.3.7
command-not-found==0.3
contextvars==2.4
crcmod==1.7
cryptography==2.1.4
cupshelpers==1.0
dataclasses==0.8
decorator==5.0.7
defer==1.0.6
defusedxml==0.7.1
deprecation==2.1.0
distlib==0.3.1
distro-info===0.18ubuntu0.18.04.1
Django==3.2.3
entrypoints==0.3
espn-scraper==0.14.16
facebook-sdk==3.1.0
fail2ban==0.10.2
filelock==3.0.12
Flask==1.1.1
fpdf==1.7.2
gast==0.3.3
google-pasta==0.2.0
grpcio==1.28.1
h5py==2.10.0
httplib2==0.9.2
idna==2.10
IMAPClient==2.1.0
immutables==0.15
importlib-metadata==4.0.1
I have generated the requirements.txt using pip freeze > requirements.txt
Edit Adding Build log:
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 559 bytes | 559.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> Using Python version specified in Pipfile.lock
remote: -----> Requirements file has been changed, clearing cached dependencies
remote: -----> Installing python-3.8.10
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing dependencies with Pipenv 2020.11.15
remote: Installing dependencies from Pipfile.lock (019894)...
remote: -----> Installing SQLite3
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 64.1M
remote: -----> Launching...
remote: Released v10
remote: https://fierce-chamber-66326.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/fierce-chamber-66326.git