I am trying to use ipywidgets with Google Colaboratory, and (as with plotly) the simplest example from the docs does not work. The code below shows a slider in a local notebook but only returns 10 and <function __main__.f>
in a Google notebook.
!pip install ipywidgets
from ipywidgets import interact
def f(x):
return x
interact(f, x=10)
Is there another custom initialization that I could use to enable the widgets?
Update: core ipywidgets
now work in Colab! In particular, the base, controls, FileUpload, Image, and output widgets all work in colab. Third-party widgets still do not work.
(Tweaked original answer): ipywidgets
don't Just Work with Colab: we have a different security model, wherein each output is in its own iframe (with a different origin than the main Colab page). This prevents ipywidgets from working without changes on the Colab side.