question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Streamlit in Electron

See original GitHub issue

Is there a future for electron deployment of streamlit?


streamlit electron app.py

Streamlits target demographic (seemingly the Data Science / ML / AI community) often has apps which consume a lot of resources. RAM for loading data used by the app can be quite a bit- pair this with st.cache and in a few hours/days time your streamlit app needs to be killed / controlled / scaled. That is fine (and good for AWS’ profit), but why not be able to distribute the app across its users so they can run it on their machine (and use their resources). This is easy enough if your streamlit users are capable of running streamlit run .. in their terminal. However, who are the users of these apps? Oftentimes they will be other engineers / programmers sure - but I think a substantial chunk of the user-base of streamlit apps is a non-technical audience. We send links to streamlit apps to management / non-technical members of the organization constantly I would much rather send them an S3 link to download an electron app and not worry about scaling up the AWS instance(s) hosting it. Sure, they have to have python and some dependencies - but those are relatively easy to control by IT and can often involve little user work. Furthermore, we could maybe have a future where the streamlit build electon command could bundle dependencies? I am not sure - but it seems possible.

Streamlit seems well-positioned for this to be possible. It is trivial to “fake it”. Just do something like this to get an MVP.

import streamlit as lit  # you guys really dropped the ball on this not being the suggested import
# idk - maybe it is too z00mer.

def main():
    lit.sidebar.title("Electron")
    lit.sidebar.info("The Electron Slide...")
    lit.sidebar.slider('How "nativive"?', 0, 100, 50)
    lit.title("Streamlit in `Electron`")

if __name__ == "__main__":
    main()

Run it,

streamlit run app.py

Take the starter electron app from here. and change literally 1 line (:16)

mainWindow.loadURL('http://localhost:8501/')  // or wherever you served

And…

image


I am just opening this issue to see if you guys (and the community) think this has any legs. I am not sure of the specifics. For example,

streamlit (electron|run_electron) app.py  # for local testing and development
streamlit build -t electron app.py <name>  # for building and bundling dependencies
# to a downloadable launcher? 
...

Could there be electron-specific component implementations (so sidebar could be a native window), or tab support, keyboard shortcuts, etc? Could session state be saved to disk and loaded on app start to preserve state? Or maybe this is all a terrible idea… (also if there is another discussion of this already somewhere else (I couldn’t find one) lmk and this can just be closed)


Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you’d like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:17
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

6reactions
SimonBiggscommented, Apr 22, 2020

Hi @DylanModesitt,

I completely agree, this is a wide open field of opportunity. In fact, just a few nights ago I was fiddling with just this. Your post encouraged me to bundle it up into a neat little easy to use prototype.

See https://github.com/pymedphys/pymedphys/tree/master/streamlit-bundle.

Essentially, within a library that I manage I have just added a little command line tool that does some parts of what you describe. Run it within a directory that contains both an app.py and a requirements.txt and it will create for you an installation exe that has an embedded Python installation bundled within it.

You require an installation of yarn, my library tool pymedphys (https://github.com/pymedphys/pymedphys), and if you’re building this Windows exe on a Linux machine you’ll also need wine installed. See https://github.com/pymedphys/pymedphys/tree/master/streamlit-bundle for more info.

Have this little utility carry with it all the warnings of a rough and ready prototype.

2reactions
FHU-yezicommented, May 4, 2021

My App’s user isn’t developer so they can not install python enviroment on computer. I want to find out a way which can build an .exe file. So that I can send this file to my user, and they can run my app with just one-cilck.

I don’t care which the app use browner or not. If the file size can be smaller, that will be a perfect way to use Streamlit.

(My first language isn’t English, so if you found some error in my comment, please tell me and improve my standard of English.)

Best wishes, yezi.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streamlit + Wasm + Electron = Desktop app!
As a part of the stlite project (a forum post), I created a toolkit to package your Streamlit app into a standalone desktop...
Read more >
Creating a Streamlit Executable - PyMedPhys
This document details the process undergone to create an Electron application that embeds streamlit. The result is an easily shareable binary built for...
Read more >
Easily create installable GUIs with a single streamlit python ...
Streamlit is an awesome, awesome, awesome tool. If you haven't seen it yet, ... This bundler tool bundles it all up inside Electron....
Read more >
Picking Streamlit, Nativefier and Electron at Stack Overflow
We have a python app currently built with Streamlit. In order to deliver this to customers, we need to shield the codebase and...
Read more >
Streamlit meets WebAssembly - stlite - DEV Community ‍ ‍
Streamlit is a web app framework with which we can create interactive web apps only with Python coding. It is especially famous and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found