The message is that the app was successfully deployed but when I load the app it display this error:
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
My logs are indicating some errors but what is that I am doing wrong?
when run:
$ heroku logs -a disastresponse --tail
this is the output:
2022-02-11T04:06:42.642514+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-02-11T04:06:42.642515+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-02-11T04:06:42.642516+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-02-11T04:06:42.642516+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-02-11T04:06:42.642516+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
2022-02-11T04:06:42.642517+00:00 app[web.1]: ModuleNotFoundError: No module named 'app'
2022-02-11T04:06:42.642579+00:00 app[web.1]: [2022-02-11 04:06:42 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-02-11T04:06:42.676775+00:00 app[web.1]: [2022-02-11 04:06:42 +0000] [4] [WARNING] Worker with pid 10 was terminated due to signal 15
2022-02-11T04:06:42.776963+00:00 app[web.1]: [2022-02-11 04:06:42 +0000] [4] [INFO] Shutting down: Master
2022-02-11T04:06:42.777013+00:00 app[web.1]: [2022-02-11 04:06:42 +0000] [4] [INFO] Reason: Worker failed to boot.
Procfile:
web: gunicorn app:run
requirements.txt
flask==2.0.2
gunicorn==20.1.0
joblib==1.1.0
nltk==3.6.5
plotly==5.1.0
numpy==1.22.2
pandas==1.4.0
pip==21.2.4
regex==2021.8.3
scikit-learn==1.0.1
scipy==1.7.3
sqlalchemy==1.4.27
Here all my run.py imports:
import json
import plotly
import pandas as pd
import numpy as np
import os
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import word_tokenize
from flask import Flask
from flask import render_template, request, jsonify
from plotly.graph_objs import Bar
# from sklearn.externals import joblib
import joblib
from sqlalchemy import create_engine
app = Flask(__name__)
Am I missing something?
Your Gunicorn argument is backwards.
Since your app object is called app
and it is in a file called run.py
, you should launch Gunicorn like this:
web: gunicorn run:app
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.