Jupyter Notebooks 不显示进度条 [英] Jupyter Notebooks not displaying progress bars

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

问题描述

我正在尝试在 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?

推荐答案

答案在这个 GitHub 问题.

关键是确保您使用以下命令启用了 ipywidgets 笔记本扩展:

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

jupyter nbextension enable --py widgetsnbextension

对于旧的 JupyterLab 2.0,您还需要 安装 JupyterLab 扩展:

For the old JupyterLab 2.0 you'll also need to install the JupyterLab extension:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

对于旧的 JupyterLab 2.0,使用上述命令安装 JupyterLab 扩展需要您Node.js 安装.Node.js 网站上的安装程序包括 npm,它也是命令正常运行所必需的.

For the old JupyterLab 2.0 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.

使用 JupyterLab 3.0 时,当您使用 pipconda 安装扩展程序时,该扩展程序将与 ipywidgets 一起自动安装.JupyterLab 3.0 不再需要 Node.js.

When using JupyterLab 3.0, the extension will be auto-installed together with ipywidgets when you install it with pip or conda. Node.js is no longer required for JupyterLab 3.0.

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

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