5

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?

orome
  • 45,163
  • 57
  • 202
  • 418

1 Answers1

11

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.

James A. Bednar
  • 3,195
  • 1
  • 9
  • 13
  • A shorthand for setting environment is %env magic. `%env HV_DOC_HTML=true` – korakot Apr 04 '19 at 10:56
  • It's weird as holoviews works fine in Kaggle notebooks. – qAp May 18 '20 at 02:34
  • 2
    Kaggle notebooks are essentially just ordinary Jupyter, which is already well supported, while colab is a highly customized fork of Jupyter that diverged from the main branch quite some time ago and (mostly for security reasons) has disabled most of the machinery for JS/Python communication. Colab is now adding new APIs to allow packages to support it, so I hope there will be progress on this front soon. – James A. Bednar May 19 '20 at 20:27