简体   繁体   中英

Heroku app successfully deploying, but receiving application error

I am new with pyhton, an I tried to deploy my simple app on Heroku (deployment logs) but I got and error:

Application 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 heroku logs --tail

Deploy log:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python                                                                                                                             -----> Python app detected
-----> Using Python version specified in runtime.txt
!     Python has released a security update! Please consider upgrading to python-3.8.13
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.8.12
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Discovering process typesProcfile declares types -> web
-----> Compressing...Done: 230.1M
-----> Launching...Released v10
https://penguins-web-app.herokuapp.com/ deployed to Heroku

The deploying log is ok, but I cant find a possible problem (sorry for the silly question).

LOG Detailed:

2022-03-29T00:11:57.794613+00:00 app[api]: Initial release by user atilio.grondoa@ufrgs.br
2022-03-29T00:11:57.794613+00:00 app[api]: Release v1 created by user atilio.grondona@ufrgs.br
2022-03-29T00:11:57.973779+00:00 app[api]: Enable Logplex by user atilio.grondona@ufrgs.br
2022-03-29T00:11:57.973779+00:00 app[api]: Release v2 created by user atilio.grondona@ufrgs.br
2022-03-29T00:15:40.000000+00:00 app[api]: Build started by user atilio.grondona@ufrgs.br
2022-03-29T00:16:46.591350+00:00 app[api]: Release v3 created by user atilio.grondona@ufrgs.br
2022-03-29T00:16:46.591350+00:00 app[api]: Deploy d008069a by user atilio.grondona@ufrgs.br
2022-03-29T00:16:46.607351+00:00 app[api]: Scaled to web@1:Free by user atilio.grondona@ufrgs.br
2022-03-29T00:17:03.515239+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run pinguins-app.py`
2022-03-29T00:17:05.173635+00:00 app[web.1]: setup.sh: 2:
2022-03-29T00:17:07.198607+00:00 app[web.1]: Traceback (most recent call last):
2022-03-29T00:17:07.199093+00:00 app[web.1]: File "/app/.heroku/python/bin/streamlit", line 8, in <module>
2022-03-29T00:17:07.199263+00:00 app[web.1]: sys.exit(main())
2022-03-29T00:17:07.199278+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
2022-03-29T00:17:07.199694+00:00 app[web.1]: return self.main(*args, **kwargs)
2022-03-29T00:17:07.199708+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1055, in main
2022-03-29T00:17:07.200079+00:00 app[web.1]: rv = self.invoke(ctx)
2022-03-29T00:17:07.200093+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
2022-03-29T00:17:07.200604+00:00 app[web.1]: return _process_result(sub_ctx.command.invoke(sub_ctx))
2022-03-29T00:17:07.200620+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
2022-03-29T00:17:07.201079+00:00 app[web.1]: return ctx.invoke(self.callback, **ctx.params)
2022-03-29T00:17:07.201094+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 760, in invoke
2022-03-29T00:17:07.201423+00:00 app[web.1]: return __callback(*args, **kwargs)
2022-03-29T00:17:07.201441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/cli.py", line 172, in main_run
2022-03-29T00:17:07.201594+00:00 app[web.1]: bootstrap.load_config_options(flag_options=kwargs)
2022-03-29T00:17:07.201609+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/bootstrap.py", line 318, in load_config_options
2022-03-29T00:17:07.201799+00:00 app[web.1]: config.get_config_options(force_reparse=True, options_from_flags=options_from_flags)
2022-03-29T00:17:07.201814+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/config.py", line 1020, in get_config_options
2022-03-29T00:17:07.202187+00:00 app[web.1]: _update_config_with_toml(file_contents, filename)
2022-03-29T00:17:07.202202+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/config.py", line 897, in _update_config_with_toml
2022-03-29T00:17:07.202538+00:00 app[web.1]: parsed_config_file = toml.loads(raw_toml)
2022-03-29T00:17:07.202553+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/toml/decoder.py", line 213, in loads
2022-03-29T00:17:07.202700+00:00 app[web.1]: raise TomlDecodeError("Key name found without value."
2022-03-29T00:17:07.202774+00:00 app[web.1]: toml.decoder.TomlDecodeError: Key name found without value. Reached end of line. (line 1 column 2 char 1)
2022-03-29T00:17:07.765837+00:00 heroku[web.1]: Process exited with status 1
2022-03-29T00:17:07.828776+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-29T00:17:07.835310+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-29T00:17:19.895825+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run pinguins-app.py`
2022-03-29T00:17:20.942050+00:00 app[web.1]: setup.sh: 2:
2022-03-29T00:17:22.226349+00:00 app[web.1]: Traceback (most recent call last):
2022-03-29T00:17:22.226369+00:00 app[web.1]: File "/app/.heroku/python/bin/streamlit", line 8, in <module>
2022-03-29T00:17:22.226447+00:00 app[web.1]: sys.exit(main())
2022-03-29T00:17:22.226459+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
2022-03-29T00:17:22.226813+00:00 app[web.1]: return self.main(*args, **kwargs)
2022-03-29T00:17:22.226824+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1055, in main
2022-03-29T00:17:22.227152+00:00 app[web.1]: rv = self.invoke(ctx)
2022-03-29T00:17:22.227168+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
2022-03-29T00:17:22.227604+00:00 app[web.1]: return _process_result(sub_ctx.command.invoke(sub_ctx))
2022-03-29T00:17:22.227617+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
2022-03-29T00:17:22.228023+00:00 app[web.1]: return ctx.invoke(self.callback, **ctx.params)
2022-03-29T00:17:22.228025+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/click/core.py", line 760, in invoke
2022-03-29T00:17:22.228267+00:00 app[web.1]: return __callback(*args, **kwargs)
2022-03-29T00:17:22.228282+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/cli.py", line 172, in main_run
2022-03-29T00:17:22.228388+00:00 app[web.1]: bootstrap.load_config_options(flag_options=kwargs)
2022-03-29T00:17:22.228391+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/bootstrap.py", line 318, in load_config_options
2022-03-29T00:17:22.228539+00:00 app[web.1]: config.get_config_options(force_reparse=True, options_from_flags=options_from_flags)
2022-03-29T00:17:22.228550+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/config.py", line 1020, in get_config_options
2022-03-29T00:17:22.228856+00:00 app[web.1]: _update_config_with_toml(file_contents, filename)
2022-03-29T00:17:22.228868+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/streamlit/config.py", line 897, in _update_config_with_toml
2022-03-29T00:17:22.229139+00:00 app[web.1]: parsed_config_file = toml.loads(raw_toml)
2022-03-29T00:17:22.229150+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/toml/decoder.py", line 213, in loads
2022-03-29T00:17:22.229256+00:00 app[web.1]: raise TomlDecodeError("Key name found without value."
2022-03-29T00:17:22.229283+00:00 app[web.1]: toml.decoder.TomlDecodeError: Key name found without value. Reached end of line. (line 1 column 2 char 1)
2022-03-29T00:17:22.524612+00:00 heroku[web.1]: Process exited with status 1
2022-03-29T00:17:22.576376+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-29T00:17:24.000000+00:00 app[api]: Build succeeded
2022-03-29T00:17:27.995087+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=web-penguin.herokuapp.com request_id=7aab630c-d2c
d-4b79-90a4-cb2057d7322f fwd="189.6.210.213" dyno= connect= service= status=503
bytes= protocol=https
2022-03-29T00:17:28.921373+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=web-penguin.herokuapp.com request_id=3
1c1f9ef-b3c0-439d-ae94-885a17afaf14 fwd="189.6.210.213" dyno= connect= service=status=503 bytes= protocol=https

My python code:

import streamlit as st
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier

st.write("""
# Simple Iris Flower Prediction App
This app predicts the **Iris flower** type!
""")

st.sidebar.header('User Input Parameters')

def user_input_features():
    sepal_length = st.sidebar.slider('Sepal length', 4.3, 7.9, 5.4)
    sepal_width = st.sidebar.slider('Sepal width', 2.0, 4.4, 3.4)
    petal_length = st.sidebar.slider('Petal length', 1.0, 6.9, 1.3)
    petal_width = st.sidebar.slider('Petal width', 0.1, 2.5, 0.2)
    data = {'sepal_length': sepal_length,
            'sepal_width': sepal_width,
            'petal_length': petal_length,
            'petal_width': petal_width}
    features = pd.DataFrame(data, index=[0])
    return features

df = user_input_features()

st.subheader('User Input parameters')
st.write(df)

iris = datasets.load_iris()
X = iris.data
Y = iris.target

clf = RandomForestClassifier()
clf.fit(X, Y)

prediction = clf.predict(df)
prediction_proba = clf.predict_proba(df)

st.subheader('Class labels and their corresponding index number')
st.write(iris.target_names)

st.subheader('Prediction')
st.write(iris.target_names[prediction])
#st.write(prediction)

st.subheader('Prediction Probability')
st.write(prediction_proba)

My file system dont have the config.toml, int the flher.streamlit/ there is 2 files.stable_random_id and credentials (the last one I delete it). I tryied to create by my own the config.toml but not worked anyway. I used this in the config.toml:

mkdir -p ~/.streamlit/
echo "\
[server]\n\
port = $PORT\n\
enableCORS = false\n\
headless = true\n\
\n\
" > ~/.streamlit/config.toml

@ferdy here is the log error message of heroku:

Heroku log error

Based just on the sample here it looks like you've bound it to a version of python that has a known security issue, but otherwise I don't see any errors in the sample here. If you update your requirements to 3.8.13, it should get rid of the error, since there's 85 vulnerabilities in 3.8.12.

I can successfully deploy in heroku with your code.

link: https://stdemo.herokuapp.com/ [deleted]

requirements.txt

streamlit==1.8.0
scikit-learn==1.0.2
click==8.0.4

Procfile

web: sh setup.sh && streamlit run app.py

setup.sh

mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml

app.py
Use your code.

Problem solved: use CLI to deploy and work fine.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM