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