I'm trying to deploy a Flask app to Heroku. After deploying, application crashes and I get an error ModuleNotFoundError: No module named 'app'.
Project structure:
.
├── ./espncricinfo
│ ├── ./exceptions.py
│ ├── ./__init__.py
│ ├── ./match.py
│ ├── ./player.py
│ ├── ./summary.py
│
├── ./pycricbuzz
│ ├──./cricbuzz.py
│ ├──./ __init__.py
├── ./pycricket
│ ├── ./cricket.py
│ ├──./ __init__.py
├── ./static
│ ├── ./bblpics
│ ├── ./fonts
│ ├── ./images
│ ├── ./favascripts
│ ├── ./stylesheets
├── ./templates
│ ├── ./index.html
│ ├── ./base.html
│ ├── ./app.html
│ ├── ./Smmary.html
│ ├── ./Scorecard.html
│ ├── ./News.html
├── ./__init__.py
│
├── ./Procfile
│
├── ./requirements.txt
│
├── ./runtime.txt
│
├── ./bbl.py
│
└── ./score.py
I'm doing in virtualenv I pip installed these dependices pip install Flask pip install requests pip install pytz pip install praw pip install beautifulsoup4 pip install google-api-python-client pip install python-dateutil pip install python-espncricinfo pip install pandas pip install gunicorn
pip freeze > requirements.txt
echo web: gunicorn app:app > Procfile
echo python-3.6.4 >runtime.txt
git init
heroku login
heroku create the-wall-cricket-scores
git add .
git commit -m "fdf"
git push heroku master
heroku open
This is my main init.py
app = Flask(__name__)
if __name__=="__main__":
app.run(debug=True)
Procfile web: gunicorn app:app runtime.txt python-3.6.4
Requirements.txt-
beautifulsoup4==4.6.0
bs4==0.0.1
certifi==2018.1.18
chardet==3.0.4
click==6.7
dateparser==0.7.0
Flask==0.12.2
google-api-python-client==1.6.5
gunicorn==19.7.1
httplib2==0.10.3
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
numpy==1.14.0
oauth2client==4.1.2
pandas==0.22.0
praw==5.3.0
prawcore==0.13.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
python-dateutil==2.6.1
python-espncricinfo==0.3.1
pytz==2018.3
regex==2018.2.8
requests==2.18.4
rsa==3.4.2
six==1.11.0
tzlocal==1.5.1
update-checker==0.16
uritemplate==3.0.0
urllib3==1.22
Werkzeug==0.14.1
I get an error as follow : Error full details:
2018-02-20T06:52:40.000000+00:00 app[api]: Build succeeded
2018-02-20T06:54:00.350992+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2018-02-20T06:54:01.598198+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2018-02-20T06:54:03.409972+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-02-20T06:54:03.413413+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Listening at: http://0.0.0.0:34331 (4)
2018-02-20T06:54:03.413643+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Using worker: sync
2018-02-20T06:54:03.420766+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Booting worker with pid: 8
2018-02-20T06:54:03.431463+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] Exception in worker process
2018-02-20T06:54:03.431467+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.431469+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.431471+00:00 app[web.1]: worker.init_process()
2018-02-20T06:54:03.431473+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.431474+00:00 app[web.1]: self.load_wsgi()
2018-02-20T06:54:03.431476+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.431478+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.431480+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.431482+00:00 app[web.1]: self.callable = self.load()
2018-02-20T06:54:03.431483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.431485+00:00 app[web.1]: return self.load_wsgiapp()
2018-02-20T06:54:03.431487+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.431489+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-02-20T06:54:03.431490+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.431492+00:00 app[web.1]: __import__(module)
2018-02-20T06:54:03.431534+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.431765+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-02-20T06:54:03.473017+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] Booting worker with pid: 9
2018-02-20T06:54:03.484252+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [ERROR] Exception in worker process
2018-02-20T06:54:03.484255+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.484257+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.484258+00:00 app[web.1]: worker.init_process()
2018-02-20T06:54:03.484260+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.484262+00:00 app[web.1]: self.load_wsgi()
2018-02-20T06:54:03.484263+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.484265+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.484267+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.484268+00:00 app[web.1]: self.callable = self.load()
2018-02-20T06:54:03.484270+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.484271+00:00 app[web.1]: return self.load_wsgiapp()
2018-02-20T06:54:03.484273+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.484275+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-02-20T06:54:03.484277+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.484278+00:00 app[web.1]: __import__(module)
2018-02-20T06:54:03.484338+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.484677+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-02-20T06:54:03.590746+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Shutting down: Master
2018-02-20T06:54:03.590997+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-02-20T06:54:03.801591+00:00 heroku[web.1]: Process exited with status 3
2018-02-20T06:54:04.041064+00:00 heroku[web.1]: State changed from starting to crashed
2018-02-20T06:54:04.029283+00:00 heroku[web.1]: Process exited with status 3
2018-02-20T06:54:03.896607+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-02-20T06:54:03.897225+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Listening at: http://0.0.0.0:13017 (4)
2018-02-20T06:54:03.897355+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Using worker: sync
2018-02-20T06:54:03.901981+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Booting worker with pid: 8
2018-02-20T06:54:03.907379+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [ERROR] Exception in worker process
2018-02-20T06:54:03.907383+00:00 app[web.1]: Traceback (most recent call last):
2018-02-20T06:54:03.907385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-02-20T06:54:03.907387+00:00 app[web.1]: worker.init_process()
2018-02-20T06:54:03.907389+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-02-20T06:54:03.907391+00:00 app[web.1]: self.load_wsgi()
2018-02-20T06:54:03.907393+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-02-20T06:54:03.907394+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-02-20T06:54:03.907396+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-02-20T06:54:03.907398+00:00 app[web.1]: self.callable = self.load()
2018-02-20T06:54:03.907400+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-02-20T06:54:03.907402+00:00 app[web.1]: return self.load_wsgiapp()
2018-02-20T06:54:03.907404+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-02-20T06:54:03.907406+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-02-20T06:54:03.907408+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-02-20T06:54:03.907410+00:00 app[web.1]: __import__(module)
2018-02-20T06:54:03.907417+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2018-02-20T06:54:03.907561+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-02-20T06:54:03.950849+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Shutting down: Master
2018-02-20T06:54:03.950970+00:00 app[web.1]: [2018-02-20 06:54:03 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-02-20T06:54:48.667089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=the-wall-cricket.herokuapp.com request_id=ac09678c-ef2d-4f3a-9d96-f0c60232eef3 fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.281797+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=the-wall-cricket.herokuapp.com request_id=c779ab65-1b04-443a-b17b-438cfe914a17 fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.189245+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=6d88e51d-44c6-4389-aac5-c24595aad59c fwd="157.49.105.219" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:51.849753+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=501e291a-0426-477b-ab30-b9e2c00865fb fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
2018-02-20T06:54:52.823503+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=the-wall-cricket.herokuapp.com request_id=7173cf2e-806d-4675-8e9e-442624e55f1c fwd="157.49.23.47" dyno= connect= service= status=503 bytes= protocol=https
what's wrong with this, How can I successfully deploy an app??
web:gunicorn app:app
is standard Procfile. It expects that your .py file should be named app.py.
If you want to change .py name you should change Procfile as well.
web:gunicorn my_app_name:app
After that you can name your file - my_app_name.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With