IPython:ipywidgets 错误 - 代码可在 Google Colab 上运行,但不能在 Jupyter Notebook 上运行(在 2 台不同的 PC 上测试过)?
IPython: ipywidgets bug - Code working on Goolge Colab, but not on Jupyter Notebook (tested on 2 different PCs)?
此代码是一个 "Filter as you type" 文本框示例。它在 Google Colab 上运行良好,但在 Jupyter Notebook 上运行不佳。我在安装了 Jupyter Notebook 的 2 台不同的计算机(以及 2 种不同的浏览器)上进行了尝试,并且 'out' 小部件仅显示文本框,但没有其他内容。知道如何解决这个问题吗?
我试过 pip uninstall 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 的输出:
我发现这是由 NbExtensions 中的 "Limit Output" 扩展引起的。当我禁用它时,输出小部件起作用了。
此代码是一个 "Filter as you type" 文本框示例。它在 Google Colab 上运行良好,但在 Jupyter Notebook 上运行不佳。我在安装了 Jupyter Notebook 的 2 台不同的计算机(以及 2 种不同的浏览器)上进行了尝试,并且 'out' 小部件仅显示文本框,但没有其他内容。知道如何解决这个问题吗?
我试过 pip uninstall 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 的输出:
我发现这是由 NbExtensions 中的 "Limit Output" 扩展引起的。当我禁用它时,输出小部件起作用了。