Development Status
- 5 - Production/Stable
- 6 - Mature
Environment
- Console
- MacOS X
- Other Environment
- Win32 (MS Windows)
- X11 Applications
Framework
- IPython
- Jupyter
Intended Audience
- Developers
- Education
- End Users/Desktop
- Other Audience
- System Administrators
License
- OSI Approved :: BSD License
Natural Language
- English
Operating System
- MacOS :: MacOS X
- MacOS
- Microsoft :: MS-DOS
- Microsoft :: Windows
- Microsoft
- POSIX :: BSD :: FreeBSD
- POSIX :: BSD
- POSIX :: Linux
- POSIX :: SunOS/Solaris
- POSIX
- Unix
Programming Language
- Python :: 3 :: Only
- Python :: 3
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: 3.14
- Python :: 3.15
- Python :: Implementation :: IronPython
- Python :: Implementation :: PyPy
- Python :: Implementation
- Python
- Unix Shell
Topic
- Desktop Environment
- Education :: Computer Aided Instruction (CAI)
- Education :: Testing
- Office/Business
- Other/Nonlisted Topic
- Software Development :: Build Tools
- Software Development :: Libraries
- Software Development :: Libraries :: Python Modules
- Software Development :: Pre-processors
- Software Development :: User Interfaces
- System :: Installation/Setup
- System :: Logging
- System :: Monitoring
- System :: Shells
- Terminals
- Utilities
Typing
- Typed
A typed terminal progress bar library for Python. It handles custom widgets, clean output around prints and logs, multiple concurrent bars, unknown-length progress, and pipe-friendly CLI usage.
Install
pip install progressbar2
Quick start
import time
import progressbar
for item in progressbar.progressbar(range(100), desc='Loading'):
time.sleep(0.02)
Try it in your browser
Every example in the documentation runs live in the page. Press Run on any code block, no install required.
Progress with clean logs
"""A build log printing above a progress bar without corrupting it."""
from __future__ import annotations
import time
import progressbar
STEPS = 24
def main() -> None:
with progressbar.ProgressBar(
max_value=STEPS,
prefix='Build ',
redirect_stdout=True,
) as bar:
for step in range(STEPS):
if step in {8, 16}:
print(f'log: completed step {step}')
bar.update(step + 1)
# Longer than the bar's 0.05s update gate, so every step
# lands as a visible redraw.
time.sleep(0.1)
if __name__ == '__main__':
main()
Multiple bars
"""Two named bars progressing at different rates in one terminal."""
from __future__ import annotations
import sys
import time
import progressbar
STEPS = 24
def main() -> None:
with progressbar.MultiBar(fd=sys.stdout) as multibar:
build = multibar['build']
test = multibar['test']
build.max_value = STEPS
test.max_value = STEPS
for step in range(STEPS):
build.update(step + 1)
test.update(min(STEPS, max(0, round((step - 3) * 1.2))))
# Longer than the bars' 0.05s update gate, so every step
# lands as a visible redraw.
time.sleep(0.1)
# Reaching max_value doesn't finish a bar -- only finish() does.
# A MultiBar waits for every bar to report finished() before its
# context manager can exit, so without these calls the block
# above would hang forever on exit.
build.finish()
test.finish()
if __name__ == '__main__':
main()
Unknown length and animated bars
"""A bar for work whose total is not known up front."""
from __future__ import annotations
import time
import progressbar
def main() -> None:
with progressbar.ProgressBar(
max_value=progressbar.UnknownLength,
) as bar:
for value in range(0, 120, 10):
bar.update(value)
# Longer than the bar's 0.05s update gate, so every step
# lands as a visible redraw.
time.sleep(0.1)
if __name__ == '__main__':
main()
CLI usage
progressbar --progress --timer --eta --rate --bytes input.bin -o output.bin
Known terminal caveats
JetBrains IDEs need “Enable terminal in output console” for advanced terminal behavior such as MultiBar.
IDLE does not support terminal progress bars.
Jupyter buffers stdout; call sys.stdout.flush() when output appears late.
Project history
progressbar2 is based on the old Python progressbar package that was published on the now defunct Google Code. Since that project was completely abandoned by its developer and the developer did not respond to email, I decided to fork the package.
This package is still backwards compatible with the original progressbar package so you can use it as a drop-in replacement for existing projects.
Links
Documentation: https://progressbar-2.readthedocs.org/en/latest/
Bug reports: https://github.com/WoLpH/python-progressbar/issues
Package homepage: https://pypi.python.org/pypi/progressbar2