python - Jupyter笔记本不显示进度栏

标签 python jupyter-notebook jupyter-lab tqdm

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

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

产生以下文本输出,并且不显示任何进度条
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显示这些进度条的设置吗?

最佳答案

答案在this GitHub issue中。

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

jupyter nbextension enable --py widgetsnbextension

您还需要install the JupyterLab extension:
jupyter labextension install @jupyter-widgets/jupyterlab-manager

编辑:ipywidgets文档以及下面的一些注释所述,使用上面的命令安装JupyterLab扩展要求您具有Node.js installed。 Node.js网站的安装程序包含npm,该命令也需要正常运行。

关于python - Jupyter笔记本不显示进度栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57343134/

相关文章:

python - 不同编码的csv

python - 尝试安装 google.colab 失败后,我的 Jupyter 笔记本无法工作并抛出此错误 : "Uncaught exception in ZMQStream"

python - 在数据框中组织收集的条目

google-cloud-platform - 如何在本地运行 Jupyter,仅使用内部 IP 地址连接到 Google Cloud VM?

jupyter-notebook - 如何检测是在 Jupyter Notebook 还是 Lab

python - 动态添加内置方法以指向属性的内置方法

Udacity 上的 Python 示例坏了?

python - 在 Report Lab 中是否有获得 float div 的解决方法?

python - jupyterlab - 更改样式 - 字体、字体大小

尝试在 Anaconda Powershell 上安装时找不到 Python 包