Jupyter笔记本不显示进度栏 [英] Jupyter Notebooks not displaying progress bars

查看:758
本文介绍了Jupyter笔记本不显示进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Jupyter笔记本中使用一个进度条.这是一台新计算机,我通常无法正常工作:

I'm trying to get a progress bar going in Jupyter notebooks. This is a new computer and what I normally do doesn't seem to work:

from tqdm import tqdm_notebook
example_iter = [1,2,3,4,5]
for rec in tqdm_notebook(example_iter):
    time.sleep(.1)

产生以下文本输出,并且不显示任何进度条

Produces the following text output and doesn't show any progress bar

HBox(children=(IntProgress(value=0, max=5), HTML(value='')))

类似地,此代码:

from ipywidgets import FloatProgress
from IPython.display import display
f = FloatProgress(min=0, max=1)
display(f)
for i in [1,2,3,4,5]:
    time.sleep(.1)

产生此文本输出:

FloatProgress(value=0.0, max=1.0)

是否缺少让Jupyter显示这些进度条的设置?

Is there a setting I'm missing to get Jupyter to display these progress bars?

推荐答案

答案在关键是要确保使用以下命令启用ipywidgets笔记本扩展名:

The key is to ensure that you have the ipywidgets notebook extension enabled using the following command:

jupyter nbextension enable --py widgetsnbextension

您还需要安装JupyterLab扩展:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

编辑:如ipywidgets文档以及以下一些注释中所述,使用上述命令安装JupyterLab扩展要求您具有

As mentioned in the ipywidgets documentation as well as some of the comments below, installing the JupyterLab extension with the command above requires that you have Node.js installed. The installer from the Node.js website includes npm, which is also required for the command to run properly.

这篇关于Jupyter笔记本不显示进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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