Curdoc Showing up in Google Colab

I am trying to use the code that uses bokeh. showFretboard calls curdoc().add_root(self.layout) and I’m trying to let it appear on google colab so I use output_notebook. Is there a way for it to show up? Usually I need to host on local by doing this: bokeh serve --show filename.py. Thank you so much

import os
import sys
from bokeh.io import output_notebook
# from seeFretboard.SeeFretboard import SeeFretboard
from seeFretboard import SeeFretboard
fretboard = SeeFretboard("v", 1, 12)
fretboard.drawVerticalFretboard()
fretboard.addNotesAllString("0,0,2,2,0,0")
fretboard.showFretboard()
output_notebook()```

There is an example of running a Bokeh server app in a notebook here:

https://github.com/bokeh/bokeh/blob/3.1.1/examples/server/api/notebook_embed.ipynb

Basically, you need to define a factory function that generates a curdoc for your app, then pass that to show.

However please be aware that Google colab is not a standard Jupyter notebook. It is heavily modified by Google, and has restrictions and changes outside our control (e.g. limitations on Jupyter kernel access and websocket use). I cannot guarantee that Bokeh apps will function properly in colab notebooks.

Thank you Bryan, I will try that and haven’t had the time to work on the other too yet. Thanks again a lot for your help and time!

is bkapp(doc) the doc curdoc?

Yes it is what you add roots too and what backs a specific user-session.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.