Understand how to create a progress bar with Python using tqdm, rich, progressbar2, alive-progress, and manual methods. Includes code examples and install tips.
Scalable, Secure, and High-Performance Solutions for Your Business.
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.
Below are five effective ways to implement a progress bar in Python.
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:
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:
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:
Also Read: Top 20 Python Based CMS in 2025
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:
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.
Always test progress bars in the environment where your script will run, behavior may vary between CLI, Jupyter, or Windows/Linux terminals.
eSparkBiz is rated 4.9 Stars
Real People, Real Stories
See why 300+ startups & enterprises trust eSparkBiz with their software outsourcingYou can copy files in python using the shutil module which provides high level file and collection of files operations. You can also combine it…
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…
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…
Let’s discuss how our dedicated experts can help.