{"id":5210,"library":"enlighten","title":"Enlighten Progress Bar","description":"Enlighten Progress Bar is a console progress bar module for Python. It allows writing to stdout and stderr without any redirection, offering features for single or multiple progress bars, counters, and status bars, with experimental support for Jupyter Notebooks. As of version 1.14.1, it is actively maintained with regular updates and bug fixes.","status":"active","version":"1.14.1","language":"en","source_language":"en","source_url":"https://github.com/Rockhopper-Technologies/enlighten","tags":["progress bar","cli","terminal","console"],"install":[{"cmd":"pip install enlighten","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The primary entry point for managing multiple progress bars.","symbol":"get_manager","correct":"from enlighten import get_manager"},{"note":"Used for individual progress bars or counters, often instantiated via a manager.","symbol":"Counter","correct":"from enlighten import Counter"},{"note":"An Enum used for justifying status bar text.","symbol":"Justify","correct":"from enlighten import Justify"}],"quickstart":{"code":"import time\nimport enlighten\n\n# Get a manager instance to handle multiple progress bars\nmanager = enlighten.get_manager()\n\n# Create two counters/progress bars\nticks = manager.counter(total=100, desc='Ticks', unit='ticks')\ntocks = manager.counter(total=20, desc='Tocks', unit='tocks')\n\nfor num in range(100):\n    time.sleep(0.05) # Simulate work\n    print(f\"Working on item {num}\") # Output outside progress bars\n\n    ticks.update()\n    if not num % 5:\n        tocks.update()\n\n# Ensure all progress bars are cleaned up from the terminal\nmanager.stop()\n\nprint(\"Process complete!\")","lang":"python","description":"This example demonstrates how to use `enlighten` to create and manage multiple progress bars, allowing interleaved console output. It's crucial to call `manager.stop()` for proper cleanup."},"warnings":[{"fix":"Close progress bars when complete, or manage terminal height; for multi-threaded/processed applications, ensure `threaded=True` is passed to `get_manager()` to defer resize handling if other writes are expected.","message":"Terminal output can become scrambled or cut off if the number of progress bars exceeds terminal height, or if other threads/processes write to standard streams simultaneously with a resize event.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Enable 'Emulate terminal in output console' in PyCharm run configurations (Run -> Edit Configurations -> Templates -> Python).","message":"Enlighten does not work natively in the PyCharm Python console due to `sys.stdout` not referencing a valid TTY. It requires terminal emulation for 'Run' or 'Debug' modes.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To remove a bar immediately upon closing, call `counter.close(clear=True)`. Alternatively, set `leave=False` when creating the counter if you want it to be removed automatically by `manager.stop()` or when other bars take its place.","message":"Progress bars created with a `Manager` might remain visible after `close()` is called if `leave=True` (the default) or `clear=True` is not explicitly used.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always call `manager.stop()` when all progress bars are finished or use the `manager` as a context manager (`with enlighten.get_manager() as manager: ...`).","message":"Failing to call `manager.stop()` at the end of your program can leave progress bars on the terminal, consume resources, and prevent proper cleanup.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `enlighten` 1.12.0 or newer to ensure `elapsed` time accurately reflects active progress.","message":"Prior to version 1.12.0, the `elapsed` time on counters might continue to increment even after the counter was conceptually 'closed' or reached its total, leading to incorrect time measurements.","severity":"breaking","affected_versions":"< 1.12.0"},{"fix":"If your application relied on the old behavior, adjust your output logic. For the new behavior, upgrade to `enlighten` 0.14.0 or newer.","message":"Before version 0.14.0, the column position of the progress bar was not preserved when updating, always returning to the start of the line. This behavior changed to preserve column position.","severity":"breaking","affected_versions":"< 0.14.0"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}