Display tqdm in AWS Sagemaker's jupyterlab

Viewed 4085

Does anyone nows how can we have python tqdm progress bar working on a Sagemaker Jupyterlab Noteook ? The tqdm progress bar is never displayed, components are displayed as their code.

Example :

HBox(children=(FloatProgress(value=0.0, max=5234.0), HTML(value='')))

I'm aware of the usual fix describe here, but It does not work since trying to executing jupyter lab build will results in the issue describe here

Many thanks.

1 Answers

Thanks for using Sagemaker Notebooks!

I got this working by following the instructions in your links.

Note: I had to use the Jupyter terminal instead of using a magic ! from the notebook. There was a lot of output during the installation which slowed Jupyter down too much.

So in the terminal:

jupyter labextension install @jupyter-widgets/jupyterlab-manager > /dev/null

then:

jupyter nbextension enable --py widgetsnbextension

At this point you need to reload Jupyterlab in your browser. This is because the labextension build generates a new javascript bundle that you must reload to get.

Finally in the notebook:

!pip install tqdm

and then the example worked:

import time
from tqdm import tqdm_notebook

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

Hope this helps!

You should also try in a new notebook instance to ensure you are on the latest version of Jupyterlab.

Related