簡體   English   中英

Heroku 應用成功部署,但收到應用錯誤

[英]Heroku app successfully deploying, but receiving application error

我是 pyhton 的新手,我嘗試在 Heroku(部署日志)上部署我的簡單應用程序,但出現錯誤:

應用程序錯誤 應用程序發生錯誤,無法提供您的頁面。 如果您是應用程序所有者,請檢查您的日志以了解詳細信息。 您可以使用命令 heroku logs --tail 從 Heroku CLI 執行此操作

部署日志:

-----> 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 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

我的 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 個 files.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 日志錯誤

僅根據此處的示例,您似乎已將其綁定到具有已知安全問題的 python 版本,但除此之外,我在此處的示例中看不到任何錯誤。 如果將要求更新到 3.8.13,應該可以消除錯誤,因為 3.8.12 中有 85 個漏洞。

我可以使用您的代碼在 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

應用程序.py
使用您的代碼。

問題已解決:使用 CLI 部署並正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM