Picture by Creator
# Introduction Loading…
Progress bars make ready extra bearable. They present how a lot of a job has been accomplished, how a lot stays, and whether or not a loop continues to be operating or has stalled. This easy visible suggestions improves readability when executing long-running scripts.
Progress bars are particularly helpful in information processing, mannequin coaching, and machine studying workflows, the place duties could take a number of minutes and even hours to finish. As an alternative of ready with out suggestions, builders can monitor progress in actual time and higher perceive execution conduct.
On this article, we discover the highest seven Python libraries for progress bars. Every library contains instance code so you may rapidly combine it into your initiatives with minimal setup.
# 1. tqdm
tqdm is likely one of the hottest Python libraries for including progress bars to loops and iterable-based workflows. It’s light-weight, simple to combine, and works out of the field with minimal code modifications.
The library routinely adapts to completely different environments, together with terminals, notebooks, and scripts, making it a dependable selection for information processing and machine studying duties the place visibility into execution progress is necessary.
Key options:
- Computerized progress monitoring for any iterable with minimal code modifications
- Excessive efficiency with very low overhead, even for giant loops
- Clear and informative output, together with iteration pace and estimated time remaining
Instance code:
# pip set up tqdm
from tqdm import tqdm
import time
data = vary(1_000)
for document in tqdm(data, desc="Cleaning records"):
time.sleep(0.002)
Output:
Cleansing data: 100%|██████████| 1000/1000 [00:02<00:00, 457.58it/s]
# 2. wealthy
wealthy is a contemporary Python library designed to create visually interesting and extremely readable terminal output, together with superior progress bars. Not like conventional progress bar libraries, wealthy focuses on presentation, making it splendid for purposes the place readability and aesthetics matter, resembling developer instruments, dashboards, and command-line interfaces.
The progress bars in wealthy assist wealthy textual content formatting, dynamic descriptions, and easy animations. This makes it particularly helpful once you need progress indicators which might be each informative and visually polished with out including advanced logic to your code.
Key options:
- Visually wealthy progress bars with colours, styling, and easy animations
- Easy API for monitoring progress over iterables
- Seamless integration with different wealthy parts resembling tables, logs, and panels
Instance code:
# pip set up wealthy
from wealthy.progress import monitor
import time
endpoints = ["users", "orders", "payments", "logs"]
for api in monitor(endpoints, description="Fetching APIs"):
time.sleep(0.4)
Output:
Fetching APIs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:01
# 3. alive-progress
alive-progress is a Python library that focuses on creating animated and visually partaking progress bars for terminal purposes. It stands out by offering easy animations and dynamic indicators that make long-running duties simpler to observe and extra nice to look at.
This library is properly suited to scripts the place person expertise issues, resembling coaching loops, batch jobs, and command-line instruments. It provides a versatile API that enables builders to customise titles, kinds, and conduct whereas retaining the implementation simple.
Key options:
- Clean animated progress bars with dynamic indicators
- Versatile customization for titles, kinds, and refresh conduct
- Clear efficiency metrics together with elapsed time and processing pace
Instance code:
# pip set up alive-progress
from alive_progress import alive_bar
import time
epochs = 10
with alive_bar(epochs, title="Training model") as bar:
for _ in vary(epochs):
time.sleep(0.6)
bar()
Output:
Coaching mannequin |████████████████████████████████████████| 10/10 [100%] in 6.0s (1.67/s)
# 4. Halo
Halo is a Python library designed to show elegant spinner animations within the terminal. As an alternative of displaying progress as a share or bar, Halo gives visible indicators that sign an ongoing course of, making it splendid for duties the place progress can’t be simply quantified.
This library is usually used for startup routines, community calls, and background operations the place a easy standing indicator is extra acceptable than a standard progress bar. Its clear API and customizable spinners make it simple so as to add polished suggestions to command-line instruments.
Key options:
- Light-weight spinner animations for indeterminate duties
- Easy and intuitive API with begin, succeed, and fail states
- A number of built-in spinner kinds with customizable textual content
Instance code:
# pip set up halo
from halo import Halo
import time
spinner = Halo(textual content="Starting database", spinner="line")
spinner.begin()
time.sleep(3)
spinner.succeed("Database ready")
Output:
| Beginning database
✔ Database prepared
# 5. ipywidgets
ipywidgets is a Python library that allows interactive person interface parts in Jupyter notebooks, together with progress bars, sliders, buttons, and types. Not like terminal-based libraries, ipywidgets renders progress indicators instantly within the pocket book interface, making it particularly helpful for exploratory information evaluation and interactive experiments.
Progress bars created with ipywidgets combine seamlessly with pocket book workflows, permitting customers to observe long-running duties with out cluttering the output. This makes it a powerful selection for machine studying experiments, parameter tuning, and iterative analysis carried out in Jupyter environments.
Key options:
- Native progress bar rendering inside Jupyter notebooks
- Interactive UI parts past progress monitoring
- High quality-grained management over progress updates and show conduct
Instance code:
# pip set up ipywidgets
import ipywidgets as widgets
from IPython.show import show
import time
progress = widgets.IntProgress(worth=0, max=5, description="Experiments")
show(progress)
for _ in vary(5):
time.sleep(1)
progress.worth += 1
Output:
# 6. progress
progress is a light-weight Python library that gives easy and traditional progress bars for terminal-based purposes. It focuses on minimalism and readability, making it a sensible choice for scripts the place readability is extra necessary than superior styling or animations.
The library provides a number of progress indicators, together with bars, spinners, and counters, permitting builders to decide on the format that most closely fits their use case. Its simple API makes it simple to combine into present scripts with minimal modifications.
Key options:
- Easy and clear terminal progress bars
- A number of progress indicators resembling bars and spinners
- Minimal dependencies and simple integration
Instance code:
# pip set up progress
from progress.bar import Bar
import time
information = ["a.csv", "b.csv", "c.csv"]
bar = Bar("Uploading files", max=len(information))
for _ in information:
time.sleep(0.7)
bar.subsequent()
bar.end()
Output:
Importing information ████████████████████████████████ 100%
# 7. click on
click on is a Python library for constructing command-line interfaces that features built-in assist for progress bars. Not like standalone progress bar libraries, click on integrates progress monitoring instantly into CLI instructions, making it splendid for instruments which might be distributed and used from the terminal.
The progress bar supplied by click on is straightforward, dependable, and designed to work seamlessly with its command system. It’s particularly helpful when constructing information pipelines, automation scripts, or developer instruments the place progress suggestions must be a part of the command execution move.
Key options:
- Constructed-in progress bars designed particularly for command-line interfaces
- Seamless integration with click on command decorators and choices
- Dependable output dealing with for terminal-based instruments
Instance code:
# pip set up click on
import time
import click on
@click on.command()
def primary():
gadgets = listing(vary(30))
# Progressbar wraps the iterable
with click on.progressbar(gadgets, label="Processing items") as bar:
for merchandise in bar:
# Simulate work
time.sleep(0.05)
click on.echo("Done!")
if __name__ == "__main__":
primary()
Output:
Processing gadgets [####################################] 100%
Carried out!
# Comparability of Python Progress Bar Libraries
The desk under gives a easy comparability of the Python progress bar libraries lined on this article, specializing in the place they work finest and the way they’re sometimes used.
| Library | Finest Use Case | Surroundings Assist | Type |
|---|---|---|---|
| tqdm | Knowledge processing and ML loops | Terminal, Jupyter Pocket book | Easy and informative |
| wealthy | Polished CLI instruments | Terminal, Jupyter Pocket book | Colourful and styled |
| alive-progress | Animated long-running duties | Terminal, Restricted Pocket book assist | Animated and dynamic |
| Halo | Indeterminate duties | Terminal solely | Spinner-based |
| ipywidgets | Interactive experiments | Jupyter Pocket book solely | Native pocket book UI |
| progress | Easy scripts and batch jobs | Terminal solely | Minimal and traditional |
| click on | Command-line instruments | Terminal (CLI) | Practical CLI output |
Abid Ali Awan (@1abidaliawan) is a licensed information scientist skilled who loves constructing machine studying fashions. At the moment, he’s specializing in content material creation and writing technical blogs on machine studying and information science applied sciences. Abid holds a Grasp’s diploma in expertise administration and a bachelor’s diploma in telecommunication engineering. His imaginative and prescient is to construct an AI product utilizing a graph neural community for college kids scuffling with psychological sickness.



