IPython:ipywidgets错误-代码可在Goolge Colab上运行,但不能在Jupyter Notebook上运行(已在2台不同的PC上进行了测试)? [英] IPython: ipywidgets bug - Code working on Goolge Colab, but not on Jupyter Notebook (tested on 2 different PCs)?

查看:86
本文介绍了IPython:ipywidgets错误-代码可在Goolge Colab上运行,但不能在Jupyter Notebook上运行(已在2台不同的PC上进行了测试)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码是键入时过滤"文本框示例.它可以在Google Colab上正常工作,但不能在Jupyter Notebook上工作.我在安装了Jupyter Notebook的2台不同计算机(和2种不同的浏览器)上进行了尝试,"out"小部件仅显示文本框,而未显示其他任何内容.任何想法如何解决这个问题?

This code is a "Filter as you type" textbox example. It works fine on Google Colab, but not on Jupyter Notebook. I tried it on 2 different computers (and on 2 different browsers) that have Jupyter Notebook installed and the 'out' widget only displays the textbox but nothing else. Any idea how to fix this?

我尝试通过pip卸载ipywidgets,然后再次安装但没有成功.

I have tried pip uninstall ipywidgets then install again without success.

谢谢.

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的输出:

This is the output from Google Colab:

这是Jupyter Notebook的输出:

This is the output from Jupyter Notebook:

推荐答案

我发现这是由NbExtensions中的限制输出"扩展名引起的.当我禁用它时,输出窗口小部件可以正常工作.

I have discovered that this is caused by the "Limit Output" extension in NbExtensions. When I disabled it, the output widget worked.

这篇关于IPython:ipywidgets错误-代码可在Goolge Colab上运行,但不能在Jupyter Notebook上运行(已在2台不同的PC上进行了测试)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆