Install & Compatibility
Where this runs
tested against v2.11.3 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ProgBar
✓ from pyprind import ProgBar
ProgPercent
✓ from pyprind import ProgPercent
prog_bar
✓ import pyprind
for i in pyprind.prog_bar(range(n)): pass
Generator function for progress bars, often used directly within loops.
This example demonstrates how to create a progress bar using the `ProgBar` class and the `prog_bar` generator function. It initializes a progress bar with a specified number of iterations and updates it within a loop. An optional section shows how to use the `monitor=True` feature, which requires the `psutil` package.
import time
import pyprind
n = 10000000 # Number of iterations
# Using ProgBar class
bar = pyprind.ProgBar(n, title='Processing Data')
for i in range(n):
# Simulate some computation
# time.sleep(0.000001) # Uncomment to slow down and see progress
bar.update()
print(bar)
print("\nAlternatively, using the generator function:")
# Using prog_bar generator function
for i in pyprind.prog_bar(range(n), title='Another Task'):
# Simulate some computation
pass # time.sleep(0.000001)
# Example with monitor=True (requires psutil)
# try:
# bar_monitor = pyprind.ProgBar(100, monitor=True, title='Monitoring System')
# for i in range(100):
# time.sleep(0.1)
# bar_monitor.update()
# print(bar_monitor)
# except ValueError as e:
# print(f"Warning: {e}. Install psutil (pip install psutil) for monitoring.")
Debug
Known issues
gotchaEnabling CPU/memory monitoring (`monitor=True`) requires the `psutil` package to be installed. Without it, a `ValueError` will be raised.fixInstall the `psutil` package: `pip install psutil`.
affects: All versions when 'monitor=True' is used without `psutil`.
deprecatedPrior to version 2.11.0, the progress bar output would occupy two lines in the terminal. As of v2.11.0, it was consolidated to use only one line for a more compact display.fixUpgrade to `pyprind` version 2.11.0 or newer to use the single-line progress bar display.
affects: <2.11.0
breakingIn versions prior to 2.11.2, iterating over a completed `ProgBar` object could print unwanted new lines, causing display issues.fixUpdate to `pyprind` version 2.11.2 or later to prevent extra new lines after the progress bar completes.
affects: <2.11.2
gotchaOlder versions (pre-2.10.0) had issues with Jupyter Notebooks where the ETA was printed on new lines, disrupting the output format.fixUpgrade to `pyprind` version 2.10.0 or newer for improved Jupyter Notebook compatibility and display.
affects: <2.10.0
Errors
Common errors & fixes
ValueError: psutil package is required when using the `monitor` option.
Attempting to use `ProgBar(monitor=True)` or `ProgPercent(monitor=True)` without having the `psutil` library installed.
fixInstall `psutil` using pip: `pip install psutil`.
NameError: name 'pyprind' is not defined
The `pyprind` module or its classes/functions were used without being imported first.
fixAdd `import pyprind` or `from pyprind import ProgBar` (or ProgPercent) at the top of your script.
IndentationError: expected an indented block
Python relies on consistent indentation. This error often occurs in loops where `bar.update()` or similar calls are not correctly indented within the loop body.
fixEnsure all code within a block (like a `for` loop) is indented consistently, typically with 4 spaces.
Upgrade
Version history
2.11.3latest on PyPI · released Apr 18, 2021
Audit
Dependencies
psutiloptionalOptional dependency for monitoring CPU and memory usage when 'monitor=True' is set in ProgBar or ProgPercent.