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

江枫思渺然 提交于 2020-01-05 03:47:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/55504765/how-do-i-get-holoviews-to-display-in-google-colabs-notebooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!