Search code examples
pythonjupyter-notebooktqdm

progress bar update in the same line of a jupyter notebook


I love the tqdm progress bar for its simplicity. I have noted however that there are cases, where each update of the progress bar is printed in a new line of a jupyter notebook like in the following screenshot:

tqdm progress update in newline

How can I make sure that the update of a tqdm progress bar is printed in the same line in a jupyter notebook like in the following screenshot:

enter image description here

?


Solution

  • tqdm has a specific module for handling the output in jupyter notebook, tqdm_notebook:

    import time
    from tqdm import tqdm_notebook as tqdm
    
    for i in tqdm(range(10)):
       time.sleep(1)