How to Build a Progress Bar in Python?

Understand how to create a progress bar with Python using tqdm, rich, progressbar2, alive-progress, and manual methods. Includes code examples and install tips.

|

A progress bar in Python shows how much of a task has completed and useful for loops, file processing, and downloads.It’s a useful way to provide feedback to users, especially in long-running scripts or command-line applications.

The most popular and easiest method is using the tqdm library. However, there are several other libraries and approaches available. 

Different Ways to Implement a Progress Bar in Python

Below are five effective ways to implement a progress bar in Python.

Using tqdm (Most Popular)

tqdm is the most popular Python library for adding fast, responsive progress bars to your loops in the terminal or Jupyter Notebook.

Displays progress with percentage, ETA, and iterations.

from tqdm import tqdmimport time# Loop through a range with a tqdm progress bar

for i in tqdm(range(10)):

time.sleep(0.5)  # Simulate a task

Install with:

pip install tqdm

Using progressbar2 (Custom Widgets)

If you want more control, progressbar2 offers detailed widgets like percentage, elapsed time, and speed.

import progressbarimport time

# Create a progress bar with a maximum value of 100

bar = progressbar.ProgressBar(maxval=100)

bar.start()

# Simulate work while updating the bar

for i in range(100):

bar.update(i + 1)

time.sleep(0.05) # Simulate task

bar.finish() # Finish the progress bar

Install with:

pip install progressbar2

Using rich (Beautiful Output)

The rich library helps create stunning, colorful progress bars that look great in modern terminal applications.

from rich.progress import trackimport time# Loop with a styled progress bar and label

for task in track(range(100), description=”Processing…”):

time.sleep(0.03)  # Simulate task

Install with:

pip install rich

Also Read: Top 20 Python Based CMS in 2025

Using alive-progress (Smooth Animations)

alive-progress provides animated, modern progress indicators that work well for dynamic terminal environments.

from alive_progress import alive_barimport time

# Create a progress bar that runs for 100 steps

with alive_bar(100) as bar:

for i in range(100):

time.sleep(0.03)  # Simulate task

bar()  # Advance the bar by one step

Install with:

pip install alive-progress

Manual Progress Bar (No Libraries)

If you don’t want to use external libraries, you can create a simple text-based progress bar manually:

import sysimport time

# Loop to simulate 100% progress in steps

for i in range(101):

time.sleep(0.05)  # Simulate task

sys.stdout.write(‘\r’)  # Return to start of line

# Display progress bar with % complete

sys.stdout.write(“[%-50s] %d%%” % (‘=’ * (i // 2), i))

sys.stdout.flush()  # Force write to console

Lightweight option for simple CLI scripts, no libraries needed.

Tip

Always test progress bars in the environment where your script will run, behavior may vary between CLI, Jupyter, or Windows/Linux terminals.

Related

You can copy files in python using the shutil module which provides high level file and collection of files operations. You can also combine it…

09 Feb 2026

The demand for Python skills in Europe is growing as companies adopt AI driven solutions, enterprise platforms and interactive web applications. Businesses need developers who…

20 Jan 2026

Amazon CloudWatch allows you to run log insights queries using the logs client in Boto3. Below is a step by step guide to querying logs…

28 Oct 2025