I’m trying to deploy my streamlit app to heroku because I can’t host the streamlit version on GitHub Pages to ad it to my website so I am now trying it on Heroku.
The app seems to be live on Heroku, but I am getting the following error:"
KeyError: 'st.secrets has no key "consumerKey". Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? More info: https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management'
Traceback:
File "/app/.heroku/python/lib/python3.10/site-packages/streamlit/scriptrunner/script_runner.py", line 443, in _run_script
exec(code, module.__dict__)
File "/app/main.py", line 127, in <module>
positive, negative, neutral, polarity, tweet_list, positive_list, negative_list, neutral_list, neg, pos, neu, comp, keyword, noOfTweets = tf.twitter_get(user_word, num_of_tweets)
File "/app/twitterFunctions.py", line 83, in twitter_get
consumerKey = st.secrets['consumerKey']
File "/app/.heroku/python/lib/python3.10/site-packages/streamlit/secrets.py", line 228, in __getitem__
raise KeyError(_missing_key_error_message(key))```
In my setup.sh file, I have the following:
mkdir -p ~/.streamlit/
echo "\
[general]\n\
email = \"MY EMAIL ADDRESS HERE\"\n\
" > ~/.streamlit/credentials.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/secrets.toml
When I go to my secrets.toml file in .streamlit, I have all the required keys in it (and the streamlit version works, it’s just the heroku deployment that is showing the error):
consumerKey = 'THE KEY'
consumerSecret = 'THE KEY'
accessToken = 'THE KEY'
accessTokenSecret = 'THE KEY'```
It seems that the traceback is calling from the /app/.heroku directory but I can’t seem to find it, only the .streamlit path. I am assuming that might be the error but I don’t know how to fix it.