我是 pyhton 的新手,我試圖在 Heroku(部署日志)上部署我的簡單應用程式,但我得到了錯誤:
應用程式錯誤 應用程式發生錯誤,無法提供您的頁面。如果您是應用程式所有者,請查看您的日志以獲取詳細資訊。您可以從 Heroku CLI 使用命令 heroku logs --tail 執行此操作
部署日志:
-----> 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
部署日志沒問題,但我找不到可能的問題(對不起這個愚蠢的問題)。
日志詳解:
2022-03-29T00:11:57.794613 00:00 app[api]: Initial release by user [email protected]
2022-03-29T00:11:57.794613 00:00 app[api]: Release v1 created by user [email protected]
2022-03-29T00:11:57.973779 00:00 app[api]: Enable Logplex by user [email protected]
2022-03-29T00:11:57.973779 00:00 app[api]: Release v2 created by user [email protected]
2022-03-29T00:15:40.000000 00:00 app[api]: Build started by user [email protected]
2022-03-29T00:16:46.591350 00:00 app[api]: Release v3 created by user [email protected]
2022-03-29T00:16:46.591350 00:00 app[api]: Deploy d008069a by user [email protected]
2022-03-29T00:16:46.607351 00:00 app[api]: Scaled to web@1:Free by user [email protected]
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
我的python代碼:
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)
我的檔案系統沒有 config.toml,在 flher .streamlit/ 中有 2 個檔案 .stable_random_id 和憑據(我洗掉的最后一個)。我嘗試自己創建 config.toml 但無論如何都沒有作業。我在 config.toml 中使用了這個:
mkdir -p ~/.streamlit/
echo "\
[server]\n\
port = $PORT\n\
enableCORS = false\n\
headless = true\n\
\n\
" > ~/.streamlit/config.toml
@ferdy 這里是 heroku 的日志錯誤資訊:
Heroku 日志錯誤
uj5u.com熱心網友回復:
僅基于此處的示例,您似乎已將其系結到具有已知安全問題的 python 版本,否則我在此處的示例中看不到任何錯誤。如果您將您的要求更新到 3.8.13,它應該會消除該錯誤,因為 3.8.12 中有 85 個漏洞。
uj5u.com熱心網友回復:
我可以使用您的代碼在 heroku 中成功部署。
鏈接:https ://stdemo.herokuapp.com/ [已洗掉]
要求.txt
streamlit==1.8.0
scikit-learn==1.0.2
click==8.0.4
檔案
web: sh setup.sh && streamlit run app.py
安裝程式.sh
mkdir -p ~/.streamlit/
echo "\
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml
app.py
使用你的代碼。
uj5u.com熱心網友回復:
問題已解決:使用 CLI 進行部署并正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/454862.html
上一篇:如何在映射值中反向參考映射鍵?
