Saving a Bokeh Server Instance using .show() in the computer


After moths of working in an App using Bokeh and Panel y a Jupyter Notebook my final step is to move all the code done in Jupyter Lab to an app or Browser App in which the user could navigate through a Dashboard.

The code consists on a Panel+Plotly+Bokeh app with many interactive actions which activate functions made in Python. I tried using “” (being aplication the variable of the panel with which the user interacts) and i get a new tab in the browser that works fine, just as if it was running in the notebook.

It looks awesome!! and i’ve read that all is running appart from Jupyter in a Bokeh Server. Is there any way to save this app into a local file and when the user double clicks on the file it is executed (for example, it opens in the browser and displays the app with all the interactive options?)

Thanks and regards

Hi @SDSauron,

It looks great the teeth model.

You can check pyinstaller. There is more info in the following links

Basically you need to add a hook to py installer. For that you need to add a file to the hooks folder located in the Pyinstaller folder in the site packages of your python environment (What is python's site-packages directory? - Stack Overflow) with the following content

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('panel', include_py_files=True) + \
        collect_data_files('pyviz_comms', include_py_files=True) + \
        collect_data_files('bokeh')  # See

and have your panel application ( like this

import panel as pn

def func():
    return pn.Row('Hello World!')

, show=False) 

if you run pyinstaller --onefile, it will generate the build and the dist folder where you can find the exe.

1 Like

You could also have a look at this Github repo that is a proof-of-concept turning a Panel app into a Desktok app using Toga.

1 Like

The idea looks awesome, does it still preserve the interactivity of the widgets?

Yes, the executable has akl thw packagws and python encapsulated. Depending on the packages you use, some problem can arise.

1 Like

Thanks, i’ll give it a try :smiley:

Almost done!!, but i got an strange error with the pyinstaller when importing the libraries.