Jupyter Notebooks not displaying progress bars

我只是一个虾纸丫 提交于 2020-03-21 21:58:17

问题


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='')))

Similarly, this code:

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)

produces this text output:

FloatProgress(value=0.0, max=1.0)

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


回答1:


The answer is in this GitHub issue.

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

jupyter nbextension enable --py widgetsnbextension

You'll also need to install the JupyterLab extension:

jupyter labextension install @jupyter-widgets/jupyterlab-manager


来源:https://stackoverflow.com/questions/57343134/jupyter-notebooks-not-displaying-progress-bars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!