11

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.

jugo
  • 161
  • 2
  • 10

1 Answers1

9

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.

user3363678
  • 178
  • 6
  • I am using a Glue Sagemaker Jupyterlab notebook instance and cannot get this to work. The prerequisite installs work using the terminal and the pip install works but isn't recognized when in a notebook. I'm assuming it is looking in the wrong location but I have no idea where/how to find where it needs to be installed. The below code works in a notebook but I don't want everything to be "local" ```%pip install tqdm from tqdm import tqdm import time for i in tqdm(range(10)): for b in tqdm(range(10)): time.sleep(.5) print("done")``` – DataGuy Feb 05 '21 at 15:11
  • this works for me, remember to **refresh your browser** after running the commands to get it to work – Matt May 27 '22 at 11:17
  • 1
    Doesn't work for me. Between this and problems reading pickle files, I'll spend a whole day trying to get my notebook to run on Sagemaker. – Nick Koprowicz Jan 17 '23 at 22:48