Application error when deploying streamlit to heroku

Hi everyone, I’m getting an error when deploying my streamlit app to heroku.

Here’s my app.py

import streamlit as st
st.title("Hello streamlit")
st.subheader("My first streamlit app")
st.write("COVID-19 dashboard app coming soon")

Here’s my requirement.txt

streamlit

My setup.sh

mkdir -p ~/.streamlit

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

Output for heroku log --tail

2020-08-12T05:10:50.443070+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=covid19-dashboard-live.herokuapp.com request_id=d8adbea5-dc86-4b83-a2f0-1c31f43f5aee fwd="42.190.185.182" dyno= connect= service= status=503 bytes= protocol=https
2020-08-12T05:12:21.543601+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-12T05:12:30.932359+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run app.py`
2020-08-12T05:12:34.530452+00:00 app[web.1]: Traceback (most recent call last):
2020-08-12T05:12:34.530483+00:00 app[web.1]: File "/app/.heroku/python/bin/streamlit", line 5, in <module>
2020-08-12T05:12:34.530650+00:00 app[web.1]: from streamlit.cli import main
2020-08-12T05:12:34.530707+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/__init__.py", line 102, in <module>
2020-08-12T05:12:34.530979+00:00 app[web.1]: from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
2020-08-12T05:12:34.531020+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/DeltaGenerator.py", line 30, in <module>
2020-08-12T05:12:34.531235+00:00 app[web.1]: from streamlit import caching
2020-08-12T05:12:34.531275+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/caching.py", line 40, in <module>
2020-08-12T05:12:34.531522+00:00 app[web.1]: from streamlit.hashing import Context
2020-08-12T05:12:34.531562+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/hashing.py", line 40, in <module>
2020-08-12T05:12:34.531782+00:00 app[web.1]: from streamlit.folder_black_list import FolderBlackList
2020-08-12T05:12:34.531821+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/folder_black_list.py", line 39, in <module>
2020-08-12T05:12:34.532032+00:00 app[web.1]: if config.get_option("global.developmentMode"):
2020-08-12T05:12:34.532071+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 90, in get_option
2020-08-12T05:12:34.532303+00:00 app[web.1]: parse_config_file()
2020-08-12T05:12:34.532337+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 925, in parse_config_file
2020-08-12T05:12:34.533082+00:00 app[web.1]: _update_config_with_toml(file_contents, filename)
2020-08-12T05:12:34.533120+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/config.py", line 847, in _update_config_with_toml
2020-08-12T05:12:34.533733+00:00 app[web.1]: parsed_config_file = toml.loads(raw_toml)
2020-08-12T05:12:34.533772+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/toml/decoder.py", line 262, in loads
2020-08-12T05:12:34.534084+00:00 app[web.1]: original, i)
2020-08-12T05:12:34.534134+00:00 app[web.1]: toml.decoder.TomlDecodeError: Found invalid character in key name: '['. Try quoting the key name. (line 1 column 2 char 1)
2020-08-12T05:12:34.642988+00:00 heroku[web.1]: Process exited with status 1
2020-08-12T05:12:34.687483+00:00 heroku[web.1]: State changed from starting to crashed

Would really appreciate any kind of help!

just open terminal execute these commands -

  1. streamlit config show > ~/.streamlit/config.toml
  2. rm -i ~/.streamlit/config.toml

This solved it for me ^^

1 Like

I was also facing the same error and for me, it got resolved by updating the Setup.sh file like below:

mkdir -p ~/.streamlit/

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

As, the setup.sh file content that you have provided is missing one ‘/’ thus it is giving invalid character ‘[’ error.

Hope it helps!!