How to Convert a Streamlit App to an .EXE Executable

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this computer has never run any python code in its life can I run this trim it application there without installing python nor Docker nor downloading any assets from the internet this is where stlight comes into play the library enables us to run streaming applications in the browser without installing python thanks to piodi then you can convert this serverless application into a desktop executable using electron and that way your manager or your marketing team they they don't have to install conda or Docker to actually run your streaming app that just double click on the icon and and just go for a challenge accepted data fans I just created this multi-page application with some text a preview from data and the image of a penguin that's been loaded from a folder next to the script in a sub page I also load a four or four lots of Animation from the same image folder as the penguin let me show you the structure of the project at its roots is a streamlined app folder which contains our streaming script that major solder with a sub page and an image folder from which the assets are loaded from since I use plotly to plot a pandas data frame and stream it logic component to load an animation I will add them to a requirements text at the root of the project St Lite uses biodight to run python code inside your browser but not all python packages are supported yet pure python packages with wheels on Popeye will work correctly but packages or streaming components that rely on C extensions like like pandas or opencv or HD boost they need to be recompiled for piodite and you can check the supported packages in the following page this is where you see the list of all the packages that have been recompiled at the root of your project create a package.json file and copy paste the content from the SC Lite desktop readme into this file this project is now a npm project in which St light can be installed but to run an npm install you first need npm so go install it don't worry worry about me I'll have some tea actually just water I don't have tea back to a command line run npm install this will install all dependencies that are specified inside the package.json file into the node modules folder specifically for this project all the pinned versions of the dependencies are also tracked in a new package log file this file and the non-modules folder they can't be get ignored as soon as possible you don't need to push 100 megabytes of package data to GitHub and they can be regenerated from an npm install on the package.json file when the install is done all script commands from the packet.json file will be available through the npm Run command the first step is to dump our streaming app folder into a biodight project start typing the npm random command followed by the folder you want to dump this will the masts contain a stream with app.pi file this for now is a hard-coded requirement for SD Lite we also need to link the piod versions of some of our packages because they're not all supported in a piyota environment you can declare all the packages in the same line after the folder that you want to dump and to make things easier you can also pass the r flag pointing to your requirements.txt file and the damn command will do the job of parsing the dependencies in the file one by one there should now be a new build folder it contains your application code your external resources like the pages and the image folder the St light executable and the piodight version of the packages you can imagine this like a compiled for browser version of your summit app which means you'll need to rerun the dump every time you're making edit to the source code of your app before packaging the piodight compiled version of your Sumit app let's actually test that this compiled version works there's a surf script in the npm project you can run npm run serve to test the compiled version of the project but if you're running on Windows your common line will generally not recognize the line for setting an environment variable and for that I would duplicate this line after all it's it's my project I I do whatever I want rename it to serve Windows remove the environment variable from the line and then do it manually in the command line before running the serve method run the command and and wait for a little and a new window will pop out and your streaming app will be loading inside this window this usually takes a couple of seconds you can study the life cycle of the app in the developer tools it takes some time so use this time to grab a cup of tea and then subscribe to my channel oops we got a problem data fan if that ever happens to you first freak out a little bit then come back to your sensors and make sure you're using the latest version of St Lite go back to your package.json upgrade the version of the St light dependency you're using feel free to delete the nod modules in the package log file and rerun npm installed and recompile everything serve your project again wait for it and this time it works and if it doesn't then leave a comment sorry otherwise we'll halfway there we now need to package this biodite project into an electro executable desktop app we use the electron Builder package for this role which should be installed since it's specified in the package.json file here's the election build help page you will notice there all of the configurations for the packaging of your app are to put inside a build object in your package.json file that for example if you if you want to build a portable Windows executable because I don't want to install anything on my machine I head to the windows Target page and find out the configuration to write down into my pieces.json file I don't know if it's because of a story of when I tried to package a QT project from Windows to Mac OS and and it didn't work out at all but I would recommend sticking to packaging the project in on the same platform as your target platform so use a Windows machine to package for Windows use a Mac to package on Mac and use a Linux to package for Linux I haven't tried cross-platform packaging apparently it could work but I haven't tried this so I don't know if it works when you feel confident in your configuration run the disk command this runs to electron building and reads the build configuration from your package file let it work a little bit and a new dist folder makes its appearance with an executable copy and paste it somewhere on your desktop and double click on it there is our beautiful Windows portable app it works well it's a little long to load since it's running python in a sandbox chromium environment I think which is Rick created at every launch but it worked so yay hey let's make a quick last editor app here's an assets folder which contains an icon I want to use for the app head back to the configuration page of electron build look for the icon page find the icon argument and add it to package.json repackage your app and there's your icon hey real life tests I didn't actually try to transfer it yet to my older computer so we're going to do that let's put this executable file in this beautiful mongodb USB stick and let's let's see how it goes foreign [Applause] this is a very old computer this is normal [Music] proof penguin very blood perfect and lots of Animation there we go
Info
Channel: Fanilo Andrianasolo
Views: 28,963
Rating: undefined out of 5
Keywords: data analysis, how to use streamlit, learn streamlit, python, python streamlit, python web app, streamlit, streamlit multipage, streamlit release, streamlit tips, streamlit tutorial, cloud, reactjs, streamlit component, streamlit executable
Id: 3wZ7GRbr91g
Channel Id: undefined
Length: 8min 19sec (499 seconds)
Published: Wed Feb 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.