Hosting streamlit on github pages

Dear @gabe_maldonado, can you share your steps for deploying to heroku? I’m quite new to deployment, i apologize. Currently I just tried out two hours trying to deploy on heroku and i’m facing the following issues in the logs for a very simple app that is only reading data from a .csv file (yes really nth else, not even charts yet).

First Issue: no web processes

heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cds-playstore-analytics.herokuapp.com request_id=06fae25b-d1ba-4bb4-838f-84d3f88d3e1f fwd="138.75.242.168" dyno= connect= service= status=503 bytes= protocol=https

With some googling, i fixed it by incorporating a Procfile with the following:
web: gunicorn website.wsgi --log-file -

Second Issue from herokulogs --tail: ModuleNotFound: No module named 'app'

I don’t understand what is the proper folder structure or configuration that I’m missing out for deployment. Pls help! I’ve tested the streamlit locally its awesome but if I can’t deploy it then there is no real benefit for me to use Streamlit over just using jupyter notebook :confused:

1 Like

Hey there @lyqht seems like you’re making some progress. I am making the assumption that you have git and heroku cli already configured in your machine so you’re good to go there.

The way that I made it work is as follows:

  • Used VSCode
  • Created a virtual env and installed all required packages
  • Created an app.py file where I coded the sample app.
  • Once the app was running fine on my local machine I went ahead and deployed by:
  • Freezing requirements and creating a requirements.txt file
  • Creating a setup.sh file
  • Creating a Procfile

Type the following to your setup.sh file:

Change your Procfile to:

And then use the git and heroku workflow to create, commit, and push your app.

Hope this helps and let me know if this works for you.

I’m thinking about writing a tutorial on this-- I just have to find some free time.

GM

5 Likes

Thanks for the writeup for the steps you have done! I have followed your steps to create a Procfile and setup.sh. I have to restart the dynos a few times to get it to run on the new Procfile as well :confused:

This is the new error i see in the logs


Why would the web process fail to bind to $PORT?

Are you sure your setup.sh is running?
I would try to echo $PORT on the setup.sh and then check the logs to compare it with the port that streamlit is binded to.

Hey thanks for helping out!
I do see this in my logs:

Starting process with command `sh setup.sh && streamlit run website/main.py`

I’ve tried to add echo $PORT to the setup.sh but it seems that it is not producing the $PORT in the logs.

This is my setup.sh following @gabe_maldonado , without the credentials part, may i ask what is wrong?

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

echo $PORT

You have a couple of typos. Here’s mine:

mkdir -p ~/.streamlit/

echo "\
[general]\n\
email = \"your-email@domain.com\"\n\
" > ~/.streamlit/credentials.toml

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

Thank you! I got it to deploy onto heroku now! :slight_smile:
I see that my file is missing the \n after the enableCORS=false, but somehow it works for @gabe_maldonado?

1 Like

You were missing the line break but you were also redirecting to the wrong config file (./.streamlit.config.toml). I’m not sure but probably @gabe_maldonado’s solution was inspired by my initial post here, which also has the line break.

1 Like

Ah i see! Thank you :smiley:

1 Like

Glad you got it to work, @lyqht. I bet it felt awesome!
My file is missing the \n but somehow it works without throwing any errors. And thanks to @Alexandre_Domingues as well for helping out.

Yeap :slight_smile: I’m really thankful to the community.

1 Like

Thank You gabe_maldonado.
I was also getting the same error “h14” after deployment then I just added setup.sh & Procfile as you mentioned Its worked for me. Now running my streamlit app in heroku

1 Like

Hi Alexandre,

I´m a newbiee to heroku and streamlit. I would like to ask you a help to publish a python code by heroku. Could you show, send me a example ?
Thanks,

Silvio
silviolima07@gmail.com

I can already picture the command:
> streamlit hk-deploy
This would do just a few things: check that one is logged into heroku, that there is a requirements.txt, setup.sh and Procfile, then doing the right git push. If any of the required things are missing, sending them to the heroku tutorial. Of course I only just looked at the heroku tutorial for the first time 5 minutes ago, but subprocess should be able to do that work if the needed files are all in place.

3 Likes

Yeah i think it will be great to include this command! :smiley:

Hi, There,

I really need to deploy my streamlit application, I have requested an invite. Is there any chance to assist me or to explain how to deploy on pythonanyware.

Regards.

Was this a past situation? Since Streamlit gave me permission to deploy the app in GITHUB, so not sure what is going on?
I did got an error trying to deploy, is said, unable to set Github listener. Can you help me with that.

Hey @argira, this looks like a bug. I’m sending this thread to our eng team and we’ll get back to you ASAP. Given that it’s the weekend, though, the earliest you can expect is Monday.

Hey @argira ,

Could you tell me if you own the repository or if you’re part of an organization that owns it?

There was a minor Github outage recently as well, could you try again just to rule that out?