wow… amazing its work even in local host
C:\Users\hp>nativefier --name one_2 http://localhost:8501 --platform windows
wow… amazing its work even in local host
C:\Users\hp>nativefier --name one_2 http://localhost:8501 --platform windows
Hi there, how did you get it to work with localhost? Did you have to put any code in the main app to get it working? I just get a white screen like the user above mentioned.
Hi, I realized that my app only work in my machine, and the ‘app.exe’ need the exact ‘file.py’ that you use to run your streamlit app, so if you delete or move the file.py to other folder, or computer, the app.exe will not work…
As reported above, the best way is to deploy and then create the executable.
Thanks for the prompt reply!
Yeah I tried it exactly as you mentioned locally, seems it requires the py file. Will try to deploy then create the exe
Thanks again!
Hi @Edmilson_Philimone, @beep92,
The streamlit application acts as a frontend and backend, where the backend contains all the logic you put into the app. The Nativefier application grabs the generated frontend code (html, js, css) and puts it into Electron app. So it still depends on the backend to be running for all input and output to be processed. So the streamlit app will indeed need to be deployed somewhere in order for the nativefier application to work correctly.
My explanation might be a bit off here and there, but this is my understanding of it .
Hello @maarten-betman,
You’re spot on; I researched the Nativefier application a bit right after, and it just extracts the frontend as an exe as you mentioned, not really extracting the full application - so I can’t use it anyways (not really a solution for offline use).
I’ll have to continue my research on making it fully usable offline as a deployed application .
Appreciate your response!
Hi @beep92,
Good to know
I dockerized a couple of streamlit application for offline usage (I work quite remote sometimes). Pulling the image will of course require internet, but there after should be no problem. If you don’t want to put the image on dockerhub there’s some pretty affordable private repo options or you can package the image as a tarball (I believe). For the less tech-savy users you can make a small batch script they can run once to get the container up for the first time, there after they can use the Docker desktop GUI to restart containers which is quite user friendly.
You’re awesome, thank you @maarten-betman.
I will give this a try tonight, that sounds interesting - it could work for me. I just saw that docker hub costs a small monthly fee to host private repos. I will test with some dummy code and if it works, it might be the best option for now.
My users are not tech-savy at all, so the batch file is probably the best way to go to launch the app. I’ll test this out as I’m not too familiar with docker yet. I’ll report back my results
Thanks its worked only with the final command i used
nativefier URL, however takes time to connect to streamlit server and every operation take more time
Hi , I tried to do this with multiple streamlit apps but every time ,when i click the .exe file I get a white screen :
Unbelievable. I can´t believe it worked. Thanks
Are you running the streamlit server when opening the executable?
How did you deploy on MAC ?
probably
Hi,
What if the app is running on something else rather than streamlit cloud? does it work the same way?
Hi, i would love to know how to run Streamlit Apps Natively On Android, can you help me ?
Hi, this can also be an option to bundle a Streamlit app into a desktop app.
Please take a look
Hi everyone, after collecting all tips from this thread, and making some changes here and there plus some additions, I managed to get this working (meaning, using PyInstaller to produce an executable for my streamlit app). The app is quite complicated, so I detailed the steps for a rather simple app below.
To test this, create the two files below: app.py
and run.py
.
app.py
import streamlit as st
import pandas as pd
if st.button("CLICK ME"):
df = pd.DataFrame({
"Name": ["John", "Mary"],
"Age": [23, 34]
})
st.dataframe(df, use_container_width=True)
run.py
# Import here all modules that your app import explicitly, otherwise PyInstaller will not know they
# are needed and produce an executable that complains about "ModuleNotFoundError".
import pandas
import streamlit
# These imports are needed for the streamlit execution below.
import streamlit.web.cli as stcli
import sys
if __name__ == "__main__":
sys.argv=["streamlit", "run", "app.py", "--global.developmentMode=false"]
sys.exit(stcli.main())
Now, call PyInstaller as shown below (note the options!):
pyinstaller --copy-metadata streamlit --collect-data streamlit run.py
Once this is step finished (it can take a minute or so), your executable can be found under dist/run/run
(in Windows, it should be dist\run\run.exe
). Change run
by any other name you want.
Hope this works for you as it did for me (at least as of today, Nov 2nd, 2023!)
OS: Ubuntu 20.04
Package versions:
streamlit 1.13.0 pyhd8ed1ab_1 conda-forge
pyinstaller 5.1 py310ha400145_1 conda-forge