Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get HoloViews to display in Google Colabs notebooks?

I can't get any HoloViews graphics to display in any Google Colabs notebook.

For example even the simple Bokeh example right out fo the HoloViews introduction

points = hv.Points(np.random.randn(500,2))
points.hist(num_bins=51, dimension=['x','y'])

fails to show anything, without any error being reported, while the same code (and all example code from HoloViews) works fine in local Jupyter notebooks.

If I download the Colabs notebook locally and open it, I see the following where I say nothing for output in Colabs:

No (safe) renderer could be found for output. It has the following MIME types: application/javascript, application/vnd.bokehjs_load.v0+json

How do I get Bokeh HoloViews to display in Google Colabs notebooks?

like image 812
orome Avatar asked Jan 01 '23 02:01

orome


1 Answers

See https://github.com/pyviz/holoviews/issues/3551 . Colaboratory has some serious limitations on how it handles notebooks, and for now you have to do this once:

import os, holoviews as hv
os.environ['HV_DOC_HTML'] = 'true'

Then for every single cell with a plot in it you have to re-load the JS:

hv.extension('bokeh')

hv.Curve([1, 2, 3])

It would be great if Google could fix that, as it's unworkable in my opinion.

like image 124
James A. Bednar Avatar answered Jan 13 '23 12:01

James A. Bednar