Install & Compatibility
Where this runs
tested against v2.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.158s · 66.8MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 2.1s · import 0.137s · 20MB
66MB installed
● package 66MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ProgressBar
✓ import progressbar; pbar = progressbar.ProgressBar()
✗ from progressbar import ProgressBar
While `from progressbar import ProgressBar` might work in some contexts, the idiomatic usage often involves importing the module directly and accessing classes/functions through it, especially for widgets. For `progressbar2`, the context manager is a common pattern.
This quickstart demonstrates a basic progress bar with several common widgets. While `progressbar` (v2.5) is Python 2 only, this code is illustrative of the general API. For Python 3, it is critical to use `progressbar2` (pip install progressbar2) as a replacement. The `ProgressBar` class manages the progress, and various `widgets` define the display format.
import time
import progressbar
def main():
print("Using progressbar (v2.5) for demonstration (Python 2 example if run directly)")
print("**It is HIGHLY recommended to use 'progressbar2' instead: pip install progressbar2**\n")
# This quickstart pattern is derived from progressbar2 examples,
# which aims for backward compatibility with the original 'progressbar'.
widgets = [
'Test: ', progressbar.Percentage(),
' ', progressbar.Bar(marker=progressbar.RotatingMarker()),
' ', progressbar.ETA(),
' ', progressbar.FileTransferSpeed(),
]
# For Python 2, range(100) is fine. For Python 3, use list(range(100)) or ensure xrange behavior.
# As this library is Python 2, simple range is shown.
bar = progressbar.ProgressBar(widgets=widgets, maxval=100).start()
for i in range(100):
# Simulate some work
time.sleep(0.01)
bar.update(i + 1)
bar.finish()
print("\nExample complete.")
if __name__ == '__main__':
main()
Debug
Known issues
breakingThe `progressbar` (version 2.5) library is Python 2 only. It will not run on Python 3 environments without significant modifications or, more practically, replacement. Python 2 reached its end-of-life in 2020.fixMigrate to `progressbar2` (pip install progressbar2), which is Python 3 compatible and actively maintained.
affects: All versions of `progressbar` (specifically 2.5 and earlier)
deprecatedThe original `progressbar` library is abandoned and unmaintained. Its development ceased, leading to the creation of `progressbar2` as a direct, backward-compatible fork.fixAlways use `progressbar2` for new projects or when updating existing projects. Install via `pip install progressbar2`.
affects: All versions of `progressbar` (specifically 2.5 and earlier)
gotchaInstalling `progressbar` via `pip install progressbar` will install the old, abandoned Python 2-only version (2.5). Users intending to use an actively maintained progress bar library for Python 3 should explicitly install `progressbar2`.fixTo get the modern, maintained version, use `pip install progressbar2`. The import statement remains `import progressbar` for `progressbar2` due to backward compatibility.
affects: All versions
gotchaProgress bars might not update visually during runtime in certain environments (e.g., some IDEs, Jupyter notebooks, or when long-running tasks block the event loop in GUI applications). This can lead to the bar appearing only at the end or updating erratically.fixEnsure the output stream (typically `sys.stderr`) is flushed, or consider running long tasks in a separate thread if using GUI toolkits like Tkinter. The `progressbar2` library also offers `with progressbar.ProgressBar(...) as bar:` for better handling.
affects: All versions of `progressbar` and `progressbar2`
Errors
Common errors & fixes
ImportError: No module named progressbar
This error occurs when the `progressbar` library is not installed, or the Python environment where it's being run cannot find the installed package. This is particularly common if `progressbar2` was installed instead, or if using a virtual environment incorrectly.
fixEnsure you are using Python 2 and have installed the specific version:
`pip install progressbar==2.5`
For Python 3, it is highly recommended to use `progressbar2`:
`pip install progressbar2`
AttributeError: module 'progressbar' has no attribute 'streams'
This error typically arises when code written for the `progressbar2` library, which introduced the `streams` module for output redirection, is executed with the older `progressbar` (version 2.5), which lacks this attribute.
fixIf using Python 3 or requiring modern features like `streams`, upgrade to or install `progressbar2`:
`pip install progressbar2`
If you must use `progressbar` 2.5 (Python 2 only), modify your code to remove references to `progressbar.streams`.
TypeError: 'ProgressBar' object is not callable
This error occurs when a `ProgressBar` object from version 2.5 is treated as a callable function (e.g., `for i in progress(range(80))`), a pattern more common with iterable wrappers in `tqdm` or `progressbar2`, but not directly supported by `progressbar` 2.5's `ProgressBar` class for iteration.
fixFor `progressbar` 2.5, you must explicitly call `start()`, `update()`, and `finish()`:
```python
import progressbar
import time
bar = progressbar.ProgressBar(maxval=100, widgets=[progressbar.Bar(), progressbar.Percentage()])
bar.start()
for i in range(100):
bar.update(i + 1)
time.sleep(0.01)
bar.finish()
```
Alternatively, consider using `progressbar2` for a more `tqdm`-like iterable wrapping API. RuntimeError: You must call "start" before calling "update"
This error indicates that the `update()` method of a `progressbar` object (version 2.5) was called before its `start()` method was invoked, which is a required step in the progress bar's lifecycle.
fixAlways initialize the progress bar with `start()` before beginning to update its progress:
```python
import progressbar
import time
bar = progressbar.ProgressBar(maxval=100)
bar.start() # Call start() here
for i in range(100):
bar.update(i + 1)
time.sleep(0.01)
bar.finish()
``` TypeError: unsupported operand type(s) for +=: 'ProgressBar' and 'int'
This error happens when attempting to update a `progressbar` 2.5 instance using the `+=` operator, a syntactic sugar introduced in `progressbar2` for incrementing the progress. The older `progressbar` library does not support this shorthand.
fixInstead of `bar += increment`, use the `update()` method to modify the progress bar's value:
```python
import progressbar
import time
bar = progressbar.ProgressBar(maxval=100)
bar.start()
for i in range(10):
# Do some work
time.sleep(0.1)
bar.update(bar.currval + 10) # Manually update the current value
bar.finish()
```
For the `+=` operator, migrate to `progressbar2`. Upgrade
Version history
2.5latest on PyPI · released Jun 29, 2018
Audit
Dependencies
No dependency data recorded yet.