API Reference

tqdm

Fast extensible progress bar for Python loops and pipelines with negligible overhead and nested bars.

Official Documentation ↗
CompatibilityThis documentation covers version v4. Check the official docs for the latest API surface.

Installation

pippip install tqdm

Methods

Fast extensible progress bar for Python loops and pipelines with negligible overhead and nested bars.

Overview

tqdm instruments loops and data flows with progress bars that stay out of the way. Wrapping an iterable yields a live bar with rate, ETA, and item counts; a manual mode drives the same rendering from update calls for callbacks and pipelines.

It handles nested bars, writes that do not corrupt the display, and adapts to terminals and notebooks alike. Pandas integration via progress_apply extends the same visibility to dataframe operations.

Core Methods

The most frequently used entry points, with signatures and runnable examples:

  • tqdm(iterable) — Wraps any iterable to render a progress bar driven by iteration itself.
  • manual control — Manual progress for non-iterable work: updates advance the bar and refresh the label.
  • tqdm.write / trange — Prints without corrupting active bars, and trange wraps the range builtin as shorthand.

Usage Notes

  • Pass total when wrapping generators so percentage and ETA stay meaningful.
  • Set unit and desc once at the top to keep logs self-describing.
  • Use tqdm.auto imports in libraries so both terminals and notebooks render correctly.

Common Pitfalls

  • Forgetting to close leaves the final bar line unterminated in non-TTY output such as CI logs.
  • Bars in daemons or servers with no TTY should be disabled explicitly with disable=None or file checks.
  • Iterating with zip(tqdm(…), …) in the wrong order wraps the wrong iterable; always wrap the outermost one you want counted.

FAQ

Why does print output scramble my bar?
Regular prints overwrite the bar redraws. Use tqdm.write, which clears the line, prints, and redraws the bar, so logs and bars coexist cleanly.
How do I show progress in Jupyter?
tqdm auto-detects notebooks and renders widget bars when ipywidgets is available. Import from tqdm.notebook for explicit control, or from tqdm.auto to pick the right variant everywhere.
How much does tqdm slow my loop?
Almost nothing: the smart sync policy prints on wall-clock boundaries, not per item, so cost stays microsecond-level per iteration. Only per-item custom posthook callbacks meaningfully add overhead.