Jupyter notebook Ipywidgets与谷歌合作实验室

Jupyter notebook Ipywidgets与谷歌合作实验室,jupyter-notebook,ipywidgets,google-colaboratory,Jupyter Notebook,Ipywidgets,Google Colaboratory,我试图将ipywidgets与Google Colaboratorial一起使用,但(与之一样)最简单的方法不起作用。下面的代码显示本地笔记本中的滑块,但在Google笔记本中仅返回10和 !pip install ipywidgets from ipywidgets import interact def f(x): return x interact(f, x=10) 是否有其他自定义初始化可用于启用小部件?更新:coreipywidgets现在可以在Colab中工作!特别是,基

我试图将ipywidgets与Google Colaboratorial一起使用,但(与之一样)最简单的方法不起作用。下面的代码显示本地笔记本中的滑块,但在Google笔记本中仅返回10和

!pip install ipywidgets

from ipywidgets import interact

def f(x):
  return x

interact(f, x=10)

是否有其他自定义初始化可用于启用小部件?

更新:core
ipywidgets
现在可以在Colab中工作!特别是,基本控件、控件、文件上传、图像和输出小部件都在colab中工作。第三方小部件仍然无法工作


(调整了原始答案):
ipywidgets
不要只使用Colab:我们有一个不同的安全模型,其中每个输出都在它自己的iframe中(与主Colab页面的来源不同)。这会阻止ipywidgets在没有更改Colab端的情况下工作。

我认为现在ipywidgets正在与Google Collaboratory合作。我测试了一些装饰师,它运行得很顺利

您的代码已导致:


ipywidget
现在在colab中得到了一定程度的支持;一个值得注意的例外是
ipywidgets.Image
。请参阅。

您好,您找到解决方案了吗?我也有同样的问题不幸的是还没有解决方案:(我找到了如何启用nbextension,但仍然不起作用
!pip install widgetsnbextension!jupyter nbextension install--debug/usr/local/lib/python3.6/dist-packages/widgetsnbextension!jupyter nbextension enable--debug/usr/local/lib/python3.6/dist-packages/widgetsnbextension!jupyter nbextension list
@AlejandroQH,s)omehow,在安装/启用模块后,Jupyter服务器必须重新启动。将来有没有计划添加此功能?这是一个值得关注的问题。如果有人使用图像小部件,我尝试了文档中给出的简单代码,但单元格在执行后没有显示任何内容。@dasilvadaniel它仍然不适用于我,单元格正在运行,但没有显示绘图。当我键入
!jupyter--version
时,我得到输出:
jupyter核心:4.5.0 jupyter笔记本:5.2.2 qtconsole:4.5.2 ipython:5.5.0 ipykernel:4.6.1 jupyter客户端:5.3.1 jupyter实验室:未安装nbconvert:5.5.0 ipywidgets:7.5.0 nbformat:4.4.0 traitlets:4.3.2
。您的配置是什么?恐怕我有与您相同的设置:jupyter core:4.5.0 jupyter笔记本:5.2.2 qtconsole:4.5.2 ipython:5.5.0 ipykernel:4.6.1 jupyter客户端:5.3.1 jupyter实验室:未安装nbconvert:5.5.0 ipywidgets:7.5.0 nbformat:4.4.0 traitlets:4.3.2我的运行时间是Python3。你能检查一下吗?也许你的cookies中有什么东西或其他与你的浏览器相关的东西?是的,图像不工作对我来说是一个挫折,因为我正在尝试构建一些简单的图像标签,以帮助手动标记图像来构建新数据集
!pip install ipywidgets

# this will allow the notebook to reload/refresh automatically within the runtime
%reload_ext autoreload
%autoreload 2

from ipywidgets import interact

def f(x):
  return x

interact(f, x=10)