plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.58k stars 2.08k forks source link

enable users to create standalone desktop Dash apps #158

Open adrianoesch opened 7 years ago

adrianoesch commented 7 years ago

I think for a lot of cases people don't want to get stuff running on a server and it's too big a hassle for some to run it locally. So i was thinking, given the popularity of electron, whether it would be possible to create a standalone app that reads and publishes sth like dash-books. Guess this could be really powerful (kind of an alternative to tableau etc.). I might have a go at it if you can point me into the right direction.

chriddyp commented 7 years ago

Hey @adrianoesch - Yeah, this is a great idea. The main difficulty in doing this is managing the cross-platform python installation and dependencies. Electron makes it easy by packing everything up, as far as I'm aware, there isn't a solution that makes this as easy in Python.

Now, if the user does have python installed, then I presume that some type of "dash-reader" could use that dist of python, create a virtual env, and automatically install dependencies, and then run the app.

Or, we could leave installing the dependencies entirely up to the user. A Dash Viewer App could just make Dash files "double-clickable" - double clicking on a dash app file (.py? or a new file extension like .dash?) would open run the app automatically using the configured version of python and open that app in an electron window. This is sort of like what nteract does with jupyter notebooks.

Another future to imagine is entirely standalone Dash apps that don't use any python callbacks - basic interactivity between components is defined through a JSON spec and entirely self-contained within an HTML file. These apps would be very easily distributable. See https://github.com/plotly/dash-renderer/pull/7 for a POC

adrianoesch commented 7 years ago

Thanks for your interest. I'll have a deeper look into you answer later. I found this in the meantime, looks promising.

ned2 commented 7 years ago

It's possible the BeeWare project could be useful. In particular, Briefcase, for packaging the app for multiple OS targets.

nicolaskruchten commented 6 years ago

https://code.fb.com/data-infrastructure/xars-a-more-efficient-open-source-system-for-self-contained-executables/ could be of use here? See discussion on Hacker News: https://news.ycombinator.com/item?id=17524086

DavidRSeWell commented 6 years ago

@adrianoesch Hey, curious if you were able to make any progress in this area? I am interested in doing the same thing. The flask desktop project you linked to a year ago looks promising although I dont know if it will play nicely with dash or not but I am going to give it a go.

mungojam commented 6 years ago

@chriddyp

Electron makes it easy by packing everything up, as far as I'm aware, there isn't a solution that makes this as easy in Python.

pipenv environments seem to include all dependencies in the virtual environment folder including python itself. It would be a bit bulky, but I feel like it should be possible to use that to bundle all the python requirements.

adrianoesch commented 6 years ago

@befeltingu have a look at pywebview (https://github.com/r0x0r/pywebview). i played around a bit with it, seems to be a good desktop solution for flask/dash integration but you still have to ship everything in binaries. but this should not be too difficult either... (check the post from nicolas further up)

DavidRSeWell commented 6 years ago

@adrianoesch Thanks for the link that looks promising I will have a look. I have been looking at (https://github.com/smoqadam/PyFladesk) myself. It opens your Flask app in a Qwebview instead of using your browser.

cheak1974 commented 6 years ago

You could use Pywebview for a Cross platform Desktop App. It uses native Windows on every platform with a Web view inside and serves the App inside this Window.

https://github.com/r0x0r/pywebview/blob/master/README.md

Remi is using this as well to serve WebApps as Desktop Apps locally if you start the server with the standalone flag.

kknckk commented 6 years ago

@adrianoesch what was your final solution? PyFladesk? Everything worked fine?

filusn commented 5 years ago

Hi guys! Since there is no answer from OP for a year, I can tell you that PyFladesk works like a charm for me. To use with dash you have to replace init_gui(app) with init_gui(app.server). I still had a problem with packaging application to exe with cx_Freeze (the app crashed), but if you don't want to do this, it should work.

luquezsantiago86 commented 4 years ago

Hi guys! Since there is no answer from OP for a year, I can tell you that PyFladesk works like a charm for me. To use with dash you have to replace init_gui(app) with init_gui(app.server). I still had a problem with packaging application to exe with cx_Freeze (the app crashed), but if you don't want to do this, it should work.

Hi there, so if I want to use it in a computer with no python it is not working, isn´t it?

adamgreg commented 3 years ago

Hi, I wanted to be able to optionally run my Dash application with the look & feel of a native application (not necessarily frozen into an executable), and came across this thread.

I ended up implementing something for this using the native-web-app package to open the system web browser in its "web app" mode. It also shuts down the server, when the window is closed, exiting the application. It works well with Chrome and MS Edge on Windows, at least. I thought I'd share this gist here in case it helps anyone else searching for this:

https://gist.github.com/adamgreg/cc1abd2123cf820d9e71bf3afb5e63f5

luquezsantiago86 commented 3 years ago

Hi, I wanted to be able to optionally run my Dash application with the look & feel of a native application (not necessarily frozen into an executable), and came across this thread.

I ended up implementing something for this using the native-web-app package to open the system web browser in its "web app" mode. It also shuts down the server, when the window is closed, exiting the application. It works well with Chrome and MS Edge on Windows, at least. I thought I'd share this gist here in case it helps anyone else searching for this:

https://gist.github.com/adamgreg/cc1abd2123cf820d9e71bf3afb5e63f5

Hi Adam, looks like a really smart workaround, thanks for sharing.

LukeDev42 commented 2 years ago

@adamgreg Did you package that app into an executable?

adamgreg commented 2 years ago

@LukeDev42 No, I just run it as a script. AFAIK there no reason it wouldn't be compatible with PyInstaller though. Let me know if you have any success!

LukeDev42 commented 2 years ago

I used native-web-app to create and easy way to open my app, used pytinstaller to create an executable for the app. Worked flawlessly, didn't even need to pass any crazy options for pyinstaller. Now I'm gonna make an installer using Inno Setup then I can publish the tool.

wcheek commented 2 years ago

@LukeDev42 Could you go into a bit more detail of how you were able to create the executable using pyinstaller? What does your spec file look like? I have been running into some issue with bundling dependencies and other files.

My requirement is basically a standalone .exe that can be distributed and run without a local python installation.

luquezsantiago86 commented 2 years ago

@LukeDev42 Could you go into a bit more detail of how you were able to create the executable using pyinstaller? What does your spec file look like? I have been running into some issue with bundling dependencies and other files.

My requirement is basically a standalone .exe that can be distributed and run without a local python installation.

This is old, and is using cx_Freeze, but maybe it helps you:

https://github.com/luquezsantiago86/Standalone_Exe_App.git

LukeDev42 commented 2 years ago

@LukeDev42 Could you go into a bit more detail of how you were able to create the executable using pyinstaller? What does your spec file look like? I have been running into some issue with bundling dependencies and other files.

My requirement is basically a standalone .exe that can be distributed and run without a local python installation.

To be clear, I did not use the one exe argument. I created the directory and an installer for the user to use. The installer set up a file in their program folders and created a desktop shortcut for them.

gvwilson commented 6 months ago

Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

Ivorforce commented 5 months ago

I was recently able to build dash into a standalone using a combination of pywebview and Nuitka. Dash / Flask create a server, pywebview accesses it, and nuitka creates a standalone application (.app on macOS, .bin on Linux, .exe on Windows).

I've published my efforts into a GitHub template here: https://github.com/Ivorforce/Dash-Standalone-Boilerplate

enzofranzy commented 3 months ago

Yeah you can do it pretty easily in Windows with pywebview and autopytoexe.

You can see an example here with a Flask server inside a Dash APP to show a live stream video + an explanatation how to make your .exe

https://github.com/enzofranzy/Dash---Stream-Video-pywebview/tree/main