首页 > 解决方案 > 在 Heroku 上部署时 Python Streamlit 应用程序崩溃

问题描述

我试图在 heroku 上部署我的第一个 streamlit 应用程序,但是当我尝试打开它时应用程序崩溃了。该应用程序在本地机器上运行良好。

这是我的日志

2020-07-19T08:33:41.435526+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-19T08:34:06.942682+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run echonet.py`
2020-07-19T08:34:10.781172+00:00 app[web.1]: Traceback (most recent call last):
2020-07-19T08:34:10.781224+00:00 app[web.1]: File "/app/.heroku/python/bin/streamlit", line 5, in <module>
2020-07-19T08:34:10.781281+00:00 app[web.1]: from streamlit.cli import main
2020-07-19T08:34:10.781292+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/__init__.py", line 102, in <module>
2020-07-19T08:34:10.781914+00:00 app[web.1]: from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
2020-07-19T08:34:10.781916+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/DeltaGenerator.py", line 27, in <module>
2020-07-19T08:34:10.781922+00:00 app[web.1]: from streamlit import caching
2020-07-19T08:34:10.781923+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/caching.py", line 39, in <module>
2020-07-19T08:34:10.781923+00:00 app[web.1]: from streamlit.hashing import Context
2020-07-19T08:34:10.781923+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/hashing.py", line 40, in <module>
2020-07-19T08:34:10.782035+00:00 app[web.1]: from streamlit.folder_black_list import FolderBlackList
2020-07-19T08:34:10.782036+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/folder_black_list.py", line 39, in <module>
2020-07-19T08:34:10.782173+00:00 app[web.1]: if config.get_option("global.developmentMode"):
2020-07-19T08:34:10.782174+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 90, in get_option
2020-07-19T08:34:10.782325+00:00 app[web.1]: parse_config_file()
2020-07-19T08:34:10.782330+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 916, in parse_config_file
2020-07-19T08:34:10.782670+00:00 app[web.1]: _update_config_with_toml(file_contents, filename)
2020-07-19T08:34:10.782678+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 838, in _update_config_with_toml
2020-07-19T08:34:10.783000+00:00 app[web.1]: parsed_config_file = toml.loads(raw_toml)
2020-07-19T08:34:10.783008+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/toml/decoder.py", line 214, in loads
2020-07-19T08:34:10.783172+00:00 app[web.1]: " Reached end of line.", original, i)
2020-07-19T08:34:10.783197+00:00 app[web.1]: toml.decoder.TomlDecodeError: Key name found without value. Reached end of line. (line 1 column 25 char 24)
2020-07-19T08:34:10.853893+00:00 heroku[web.1]: Process exited with status 1
2020-07-19T08:34:10.896466+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-19T08:34:30.000000+00:00 app[api]: Build succeeded
2020-07-19T08:34:38.860206+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=echonetvgg16.herokuapp.com request_id=13dbc9c1-9aeb-462c-83f7-03c21b4fb237 fwd="42.153.37.196" dyno= connect= service= status=503 bytes= protocol=https
2020-07-19T08:34:39.189017+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=echonetvgg16.herokuapp.com request_id=d09c87de-4cbb-4ea8-aa8f-9fd3771fd953 fwd="42.153.37.196" dyno= connect= service= status=503 bytes= protocol=https

这是我的 setup.sh:

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

我的档案:

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

标签: streamlit

解决方案


尝试删除 web: 和 sh 之间的空格。例如:

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

推荐阅读