alive-progress
alive-progress is a versatile and highly customizable Python library for creating animated progress bars in the terminal. It provides visual feedback for long-running tasks with real-time throughput, Estimated Time of Arrival (ETA), and a variety of cool animations. Currently at version 3.3.0, the library maintains an active development and release cadence, offering robust features for CLI applications.
Warnings
- gotcha When running in non-interactive environments like PyCharm consoles, Jupyter notebooks, or shell pipelines, alive-progress might automatically detect a non-TTY environment and only print the final receipt. To force the progress bar display, use the `force_tty=True` argument.
- breaking The method for setting inline messages within the progress bar changed in earlier major versions. Older versions used `bar('message')` to set text while incrementing. Current versions (3.x) use `bar(text='message')` for this purpose. Calling `bar('message')` without the `text=` keyword in 3.x will likely result in an error or unexpected behavior as it would try to interpret 'message' as an increment count.
- gotcha When `alive_bar` is initialized with a `total`, calling `bar()` without arguments increments an internal counter. To manually set the progress by a percentage (e.g., 15%), you must pass the fractional value to `bar()`: `bar(0.15)`. Mixing these approaches or passing a raw count when percentage is expected (or vice-versa) without understanding the mode can lead to incorrect progress display.
- deprecated Support for older Python versions has been dropped. The library officially supports Python >=3.9.
Install
-
pip install alive-progress
Imports
- alive_bar
from alive_progress import alive_bar
- alive_it
from alive_progress import alive_it
Quickstart
import time
from alive_progress import alive_bar
TOTAL_ITEMS = 100
with alive_bar(TOTAL_ITEMS, title='Processing items') as bar:
for i in range(TOTAL_ITEMS):
# Simulate a task
time.sleep(0.05)
bar() # Update the progress bar
print("Task completed!")