【问题标题】:IPython: ipywidgets bug - Code working on Goolge Colab, but not on Jupyter Notebook (tested on 2 different PCs)?IPython:ipywidgets 错误 - 代码在 Google Colab 上工作,但在 Jupyter Notebook 上不工作(在 2 台不同的 PC 上测试)?
【发布时间】:2020-05-30 20:16:07
【问题描述】:

此代码是“键入时过滤”文本框示例。它在 Google Colab 上运行良好,但在 Jupyter Notebook 上却不行。我在安装了 Jupyter Notebook 的 2 台不同的计算机(以及 2 种不同的浏览器)上进行了尝试,并且“out”小部件仅显示文本框,而没有其他内容。知道如何解决这个问题吗?

我已经尝试 pip 卸载 ipywidgets 然后再次安装但没有成功。

谢谢。

import pandas as pd, IPython.display, ipywidgets as widgets 
out = widgets.Output()


df = pd.DataFrame ({'PLAYER':['MOHAMED SALAH', 'MESSI', 'MO SALAH', 'RONALDO', 'PELE', 'PEPE', 'MANE', 'RAMREZ']})

textbox = widgets.Text(value='', description='Player:')
display(textbox)

def display_result(value):
    value = str(value['new']).upper() 
    if "{" not in value:
        result = df[(df['PLAYER'].str.contains(value))]  
        if result.shape[0]>0:
            with out:
                out.clear_output()
                display(result)

display(out)
textbox.observe(display_result)

这是来自 Google Colab 的输出:

这是 Jupyter Notebook 的输出:

【问题讨论】:

    标签: jupyter-notebook ipython ipywidgets


    【解决方案1】:

    我发现这是由 NbExtensions 中的“限制输出”扩展引起的。当我禁用它时,输出小部件工作。

    【讨论】:

      猜你喜欢
      • 2013-04-02
      • 2012-12-01
      • 1970-01-01
      • 2017-03-15
      • 1970-01-01
      • 2017-04-10
      • 2022-09-30
      • 1970-01-01
      • 2017-02-22
      相关资源
      最近更新 更多