Skip to main content
v2026.11,986 entries · CC-BY 4.0

Jupyter Notebook Progress Bar: tqdm and ipywidgets

Add a progress bar to a Jupyter notebook loop with tqdm.auto, tqdm.notebook, pandas progress_apply or ipywidgets IntProgress, plus fixes for text-only bars.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

To show a progress bar in a Jupyter notebook, install tqdm (pip install tqdm), import it with from tqdm.auto import tqdm and wrap any loop: for x in tqdm(items):. In a notebook the bar renders as a widget in the output of the cell that creates it, and it updates as the loop runs. If you need a bar you drive yourself, the ipywidgets package provides IntProgress and FloatProgress.

What a progress bar is used for in research computing

Analysis notebooks routinely contain loops that run for minutes or hours: reading a few hundred instrument files, calling an API once per record, fitting a model per participant, or applying a function to every row of a large table. A progress bar answers three practical questions while the cell runs: is it still working, how far along is it, and roughly how long is left. That matters for reproducible work because a silent cell that appears frozen tends to get interrupted and restarted, which wastes compute and can leave partially written outputs. Related tooling is covered in the IPython guide, which explains the kernel that executes these cells.

Two libraries cover almost every case. tqdm wraps an iterable and draws the bar for you, including a native Jupyter widget. ipywidgets is the widget library that Jupyter uses for interactive controls, and it includes progress widgets you can update by hand. This page uses tqdm as the default and ipywidgets as the manual fallback.

How to install or access it

The tqdm project documents two install routes: pip install tqdm and conda install -c conda-forge tqdm. If you manage environments with conda, the Anaconda for Jupyter Notebook guide covers how kernels map to environments. Install tqdm into the environment that the notebook kernel uses, not only into the environment that launched the Jupyter server, because the loop runs in the kernel.

The ipywidgets install documentation gives pip install ipywidgets and conda install -c conda-forge ipywidgets. It adds a rule worth knowing before you debug anything: JupyterLab is usually configured automatically through the jupyterlab_widgets package, but if JupyterLab and the kernel live in different environments, install jupyterlab_widgets in the JupyterLab environment and ipywidgets in each kernel environment. For the classic Notebook, widgetsnbextension goes in the server environment and ipywidgets in the kernel environment. Extension management in general is described in the Jupyter Notebook extension guide.

Step-by-step: add a progress bar to a loop

Step 1. Import the right tqdm flavour

  1. In a notebook cell, run from tqdm.auto import tqdm. According to the tqdm documentation, tqdm.auto automatically chooses between tqdm.notebook and the plain terminal tqdm.tqdm, so the same code works in a notebook and in a script.
  2. If you prefer to be explicit, run from tqdm.notebook import trange, tqdm. This is the import shown in the tqdm notebook documentation, which describes the notebook class as an “Experimental IPython/Jupyter Notebook widget”.
  3. Avoid tqdm.autonotebook in new code. The tqdm project states that it issues a TqdmExperimentalWarning inside a notebook and advises using auto instead to suppress the warning.

Step 2. Wrap the iterable

  1. Wrap the loop’s iterable: for path in tqdm(file_paths, desc='Reading files'):. The desc argument sets a prefix shown beside the bar. If the iterable has a length, tqdm uses it as the total, so the bar has a percentage and an estimate.
  2. For a numeric loop, trange(10) is shorthand for tqdm(range(10)); in the notebook module it is defined as tqdm.notebook.tqdm(range(*args), **kwargs).

Step 3. Handle generators, streams and manual updates

  1. A generator has no length, so pass total= yourself if you know it. The tqdm parameter reference says that without a usable total only basic statistics are shown: no estimated time and no bar.
  2. To drive the bar manually, create it without an iterable and call update(). The README shows with tqdm(total=100) as pbar: followed by pbar.update(10) inside the loop. If you do not use with, call close() when finished.
  3. To change the text during the run, keep a reference and call set_description(), as in pbar = tqdm(['a', 'b', 'c', 'd']) then pbar.set_description('Processing ' + item) inside the loop.

Worked example: a progress bar over a folder of data files

This is an illustrative composite, not a record of a specific project. Suppose a lab exports one CSV file per sample and you want a combined table. In one cell:

from pathlib import Path
import pandas as pd
from tqdm.auto import tqdm

paths = sorted(Path('exports').glob('*.csv'))
frames = []
for p in tqdm(paths, desc='Reading CSV files', unit='file'):
    frames.append(pd.read_csv(p))
combined = pd.concat(frames, ignore_index=True)

Here desc labels the bar, unit replaces the default unit “it” so the rate reads in files rather than iterations, and the total is taken from len(paths) because a list has a length. The bar appears under the cell, fills as each file is read and, because leave defaults to True, stays visible after the loop ends.

pandas: progress_apply

tqdm integrates with pandas. The README shows registering the integration with tqdm.pandas(desc='my bar!') and then using progress_apply in place of apply, and progress_map in place of map. It also notes that registration can use a specific class such as tqdm.notebook.tqdm. In a notebook that gives:

from tqdm.auto import tqdm
tqdm.pandas(desc='Cleaning titles')
df['title_clean'] = df['title'].progress_apply(lambda s: s.strip().lower())

The same documentation shows progress_apply on grouped data as well. The function you pass is unchanged; only the method name changes.

Nested loops

The tqdm notebook documentation describes fully working nested bars with colour hints: blue for normal, green for completed, red for error or interrupt and light blue when there is no estimate. Its example nests a trange(3, desc='1st loop') around tqdm(range(100), desc='2nd loop'). Use distinct desc values so the two bars are easy to tell apart.

The manual alternative: ipywidgets

If you do not want tqdm, ipywidgets provides IntProgress and FloatProgress. The widget list documentation shows the constructor widgets.IntProgress(value=7, min=0, max=10, description='Loading:', bar_style='', style={'bar_color': 'maroon'}, orientation='horizontal'). The bar_style argument accepts 'success', 'info', 'warning' or 'danger'; FloatProgress takes the same arguments with floating-point values. A typical pattern is to create the widget, display it, and set its value as the loop advances. This takes more code than tqdm and gives no rate or time estimate, which is why tqdm is the better default.

Output and how to read it

A tqdm notebook bar shows the description, a percentage, the bar itself, the count completed out of the total, elapsed time, estimated remaining time and the current rate in the chosen unit. The colour carries meaning, as listed above: a bar that turns red means the loop raised an error or was interrupted, not that the data are bad. If the total is unknown you will see a count and elapsed time but no bar, as the parameter reference describes. Two arguments change what stays on screen: leave=False clears the bar when the loop ends, which is useful for an inner loop, and disable=True switches the bar off entirely, for example in a batch run where the output is not wanted. Both are documented parameters, with leave defaulting to True and disable to False. The default minimum refresh interval is 0.1 seconds (mininterval), so very fast loops do not redraw on every iteration.

For a reusable bar, the notebook module documents reset(total=None), which resets the bar to zero; combine it with leave=True if you want to run several passes with one bar.

Troubleshooting

The bar appears as plain text instead of a widget

The ipywidgets documentation attributes this to two causes. The widgets JavaScript may still be loading, so wait and refresh; or the widgets library is not installed or enabled in the front end. If you installed the package while JupyterLab was running, refresh the page or restart JupyterLab. The same page suggests jupyter lab clean when the front end is stale. Check the environment rule from the install section: ipywidgets in the kernel environment, and jupyterlab_widgets (JupyterLab) or widgetsnbextension (classic Notebook) in the server environment. The ipywidgets install page does not discuss Notebook 7 specifically, so follow the JupyterLab or classic Notebook route that matches your setup.

The notebook shows text when viewed on GitHub or NBViewer

Static viewers do not support widgets. The ipywidgets documentation notes that GitHub and NBViewer show text output because the front end lacks widget support. The bar still worked when the notebook ran; the viewer simply cannot draw it.

A TqdmExperimentalWarning appears

This comes from tqdm.autonotebook. Change the import to from tqdm.auto import tqdm, as the tqdm project advises.

There is no percentage or time estimate

The iterable has no length. Pass total=, or use a list instead of a generator if memory allows. For debugging the surrounding code, see the Jupyter Notebook debugging guide.

The bar does not clean up after an exception or break

For manually created bars, call pbar.close() or use the with statement. The tqdm README gives the same advice for early exits from asynchronous loops: either call pbar.close() or use the context-manager syntax.

Free alternatives and options compared

All options below are free, open-source packages installed with pip or conda. The data table below this article records the import or constructor, install command and the behaviour each project’s own documentation states. In short: use tqdm.auto by default so the same notebook runs in a terminal; use tqdm.notebook when you want the notebook widget explicitly; use ipywidgets IntProgress when you need to control the bar yourself or style it; and use tqdm.pandas when the slow step is a pandas apply.

Frequently asked questions

How do I add a progress bar to a Jupyter notebook loop?

Install tqdm, run from tqdm.auto import tqdm, and wrap the iterable in tqdm(). The bar appears in the output of the cell that created it, according to the tqdm documentation.

What is the difference between tqdm.auto and tqdm.notebook?

tqdm.notebook is the Jupyter widget implementation. tqdm.auto automatically chooses between it and the standard terminal version, so one import works in both places.

Can I show a progress bar for pandas apply?

Yes. Call tqdm.pandas() once, then use progress_apply instead of apply (and progress_map instead of map).

Why does my progress bar show as text like IntProgress(value=0)?

The front end is not rendering widgets: the JavaScript may still be loading, or the widgets support is not installed in the right environment. See the troubleshooting section.

Can I build a progress bar without tqdm?

Yes, with ipywidgets IntProgress or FloatProgress, updating the value as the loop runs.

Sources

Data: Jupyter notebook progress bar options: import, install and documented behaviour

Compares the progress-bar routes for Jupyter notebooks (tqdm.auto, tqdm.notebook, tqdm.pandas and ipywidgets IntProgress). Compiled from the tqdm and ipywidgets project documentation: import or constructor, install command and the behaviour each page states.

Period covered: Checked 2026-11-14.

Jupyter notebook progress bar options: import, install and documented behaviour
OptionImport or constructorInstall commandDocumented behaviour
tqdm.autofrom tqdm.auto import tqdmpip install tqdmAutomatically chooses between tqdm.notebook and tqdm.tqdm
tqdm.notebookfrom tqdm.notebook import trange, tqdmpip install tqdmNative Jupyter widget with nested bars and colour hints; described as experimental
tqdm.autonotebookfrom tqdm.autonotebook import tqdmpip install tqdmIssues TqdmExperimentalWarning in a notebook; project advises auto instead
tqdm.pandastqdm.pandas(desc='...') then df.progress_apply(...)pip install tqdmAdds progress_apply and progress_map to pandas; can register tqdm.notebook.tqdm
ipywidgets IntProgresswidgets.IntProgress(value=7, min=0, max=10, description='Loading:')pip install ipywidgetsManual widget with bar_style success/info/warning/danger and a bar_color style; FloatProgress takes floats

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about Jupyter Notebook Progress Bar: tqdm and ipywidgets

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →