{"id":13398773,"url":"https://github.com/rasbt/pyprind","last_synced_at":"2025-04-08T04:14:06.329Z","repository":{"id":13550202,"uuid":"16242221","full_name":"rasbt/pyprind","owner":"rasbt","description":"PyPrind - Python Progress Indicator Utility","archived":false,"fork":false,"pushed_at":"2021-04-18T18:08:56.000Z","size":35619,"stargazers_count":547,"open_issues_count":10,"forks_count":65,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-01T03:33:28.732Z","etag":null,"topics":["productivity","progress-bar","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rasbt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-25T23:08:12.000Z","updated_at":"2025-03-17T09:18:50.000Z","dependencies_parsed_at":"2022-08-19T17:00:49.244Z","dependency_job_id":null,"html_url":"https://github.com/rasbt/pyprind","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fpyprind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fpyprind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fpyprind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasbt%2Fpyprind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rasbt","download_url":"https://codeload.github.com/rasbt/pyprind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773719,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["productivity","progress-bar","python"],"created_at":"2024-07-30T19:00:31.568Z","updated_at":"2025-04-08T04:14:06.312Z","avatar_url":"https://github.com/rasbt.png","language":"Python","readme":"[![Build Status](https://travis-ci.org/rasbt/pyprind.svg?branch=master)](https://travis-ci.org/rasbt/pyprind)\n[![Coverage Status](https://coveralls.io/repos/rasbt/pyprind/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/rasbt/pyprind?branch=master)\n![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg)\n![Python 3](https://img.shields.io/badge/python-3-blue.svg)\n[![License](https://img.shields.io/badge/license-new%20BSD-blue.svg)](https://github.com/rasbt/pyprind/blob/master/LICENSE.txt)\n\n\n\n# PyPrind (Python Progress Indicator)\n\n\nThe `PyPrind` (Python Progress Indicator) module provides a **progress bar** and a\n**percentage indicator** object that let you track the progress of a loop structure or other iterative computation.  \nTypical applications include the processing of large data sets to provide an intuitive estimate\nat runtime about the progress of the computation.\n\n\n\n![PyPrind Demo](./images/pyprind-1.gif \"PyPrind Demo\")\n\n\u003cbr\u003e\n\n#### Progress Bars and Percentage Generators\n\n```python\nimport pyprind\n\nfor i in pyprind.prog_bar(range(n)):\n    time.sleep(timesleep) # your computation here\n```\n```\n0%                          100%\n[##############################] | ETA: 00:00:00\nTotal time elapsed: 00:00:05\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n```python\nfor i in pyprind.prog_percent(range(n)):\n    time.sleep(timesleep) # your computation here\n```\n\n```\n[10 %] Time elapsed: 00:00:01 | ETA: 00:00:04\n```\n\n#### While-loops\n\nThe `ProgBar` and `ProgPercent` classes also support while loops if desired.\nThe objects are updated inside the loop using the `update` method as shown below:\n\n```python\nimport random\nimport pyprind\nimport time\n\ntimesleep = 0.05\nrandom.seed(1)\ncollection = set()\n\nn = 100\nbar = pyprind.ProgBar(n, track_time=False, title='while example')\n\nwhile len(collection) \u003c n:\n    r = random.randint(0, 10**5)\n    if r % 7 and r not in collection:\n        collection.add(r)\n        bar.update()\n        time.sleep(timesleep)\n\nprint(bar)\n```\n```\nwhile example\n0%                          100%\n[##############################]\nTitle: while example\n  Started: 09/07/2016 13:06:58\n  Finished: 09/07/2016 13:07:03\n  Total time elapsed: 00:00:05\n```\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003ca id='advanced_tracking'\u003e\n\n#### Advanced Tracking\n\nIf you have the `psutil` package installed, you can set the `monitor=True` to track CPU and memory usage:\n\n```python\nbar = pyprind.ProgBar(n, monitor=True)\nfor i in range(n):\n    time.sleep(timesleep) # your computation here\n    bar.update()\nprint(bar)\n```\n\n```\n0%                          100%\n[##############################] | ETA: 00:00:00\nTotal time elapsed: 00:00:05\nTitle:\n  Started: 09/07/2016 13:14:09\n  Finished: 09/07/2016 13:14:14\n  Total time elapsed: 00:00:05\n  CPU %: 1.90\n  Memory %: 0.48\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n#### Choose Your Favorite Bar Style\n\n```python\nbar = pyprind.ProgBar(n, bar_char='█')\nfor i in range(n):\n    time.sleep(0.1) # do some computation\n    bar.update()\n```\n\n```\n0%                          100%\n[██████████████████████████████] | ETA: 00:00:00\nTotal time elapsed: 00:00:10\n```\n\n#### Note to PyCharm users\n\nIf you are using the PyCharm IDE, you need to pass the `sys.stdout` or `sys.err`\nas a `stream` argument to display the progress indicators correctly in the IDE. For example,\n\n```python\nimport sys\n\nbar = pyprind.ProgBar(n, stream=sys.stdout)\nfor i in range(n):\n    time.sleep(0.1) # do some computation\n    bar.update()\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n###[View more examples in an IPython Demo Notebook](http://nbviewer.ipython.org/github/rasbt/pyprind/blob/master/examples/pyprind_demo.ipynb)\n\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n\u003ca id='sections'\u003e\n\n# Sections\n\n\n- [Installation](#installation)\n- [Documentation](#documentation)\n- [Examples](#examples)\n- [Contact](#contact)\n- [Changelog](https://raw.githubusercontent.com/rasbt/pyprind/master/CHANGELOG.txt)\n\n\n\u003cp\u003e\u003ca id=\"installation\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n# Installation\n\n[[back to top](#sections)]\n\nThe most convenient way to install PyPrind is via tools like `pip` or `easy_install`:\n\n- `pip install pyprind`  \n\n-  `easy_install pyprind`  \n\n\n\nPyPrind comes without any dependencies except for the optional [psutil](https://pypi.python.org/pypi/psutil) to [monitor CPU and memory usages](#advanced_tracking). You can install `psutil` via `pip install psutil` or install it automatically with PyPrind:  \n `pip install pyprind -r requirements.txt`\n\n\n\nAlternatively, you can install PyPrind the classic way: Download the package from the Python Package Index [https://pypi.python.org/pypi/PyPrind](https://pypi.python.org/pypi/PyPrind), unzip it,\nnavigate into the unzipped directory, and use the command\n\n`python setup.py install`  \n\n\n\n\n\u003cp\u003e\u003ca id=\"documentation\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n# Documentation\n\n[[back to top](#sections)]\n\n\n\nPyPrind consists of two class objects that can visualize the progress of a computation on the output screen.  \nProgress bars are available via `ProgBar`, and percentage indicators can be used via a `ProgPercent`.  \n\n```python\n\tn = 10000000\n\tbar = pyprind.ProgBar(n)   # 1) initialization with number of iterations\n\tfor i in range(n):\n    \t# do some computation\n    \tbar.update()           # 2) update the progress visualization\n```\n\nAlternatively, the progress can be tracked via the equivalent generator functions `prog_bar` and `prog_percent`:\n\n```python\n\tfor i in pyprind.prog_bar(range(n)):\n    \t# do something\n    \tpass\n```\n\n\n\u003cbr\u003e\n\n#### Complete Parameter of Parameters and Options\n\n##### ProgBar\n\n*`ProgBar(iterations, track_time=True, width=30, bar_char='#',\n               stream=2, title='', monitor=False, update_interval=None))`*\n\n- iterations : `int`  \n    Number of iterations for the iterative computation.\n- track_time : `bool` (default: `True`)  \n    Prints elapsed time when loop has finished.\n- width : `int` (default: 30)  \n    Sets the progress bar width in characters.\n- stream : `int` (default: 2).  \n    Setting the output stream.\n    Takes `1` for stdout, `2` for stderr, or a custom stream object\n- title : `str` (default:  `''`)  \n    Setting a title for the progress bar.\n- monitor : `bool` (default: `False`)  \n    Monitors CPU and memory usage if `True` (requires `psutil` package).\n- update_interval : float or int (default: `None`)  \n    The update_interval in seconds controls how often the progress\n    is flushed to the screen.\n    Automatic mode if `update_interval=None`.\n\n##### ProgPercent\n\n*`ProgPercent(iterations, track_time=True,\n               stream=2, title='', monitor=False, update_interval=None)`*\n\n- iterations : `int`  \n    Number of iterations for the iterative computation.  \n- track_time : `bool` (default: `True`)  \n    Prints elapsed time when loop has finished.\n- stream : `int` (default: 2).  \n    Setting the output stream.\n    Takes `1` for stdout, `2` for stderr, or a custom stream object\n- title : `str` (default : `''`).  \n    Setting a title for the percentage indicator.\n- monitor : `bool` (default: `False`)  \n    Monitors CPU and memory usage if `True` (requires `psutil` package).\n- update_interval : float or int (default: `None`)  \n    The update_interval in seconds controls how often the progress\n    is flushed to the screen.\n    Automatic mode if `update_interval=None`.\n\n##### update method\n\n*`update(iterations=1, item_id=None, force_flush=False)`*\n\n- iterations : int (default: `1`)  \n    default argument can be changed to integer values\n    `\u003e=1` in order to update the progress indicators more than once\n    per iteration.\n- item_id : str (default: `None`)  \n    Print an item_id sring behind the progress bar\n- force_flush : bool (default: `False`)  \n    If True, flushes the progress indicator to the output screen\n    in each iteration.\n\n\u003cbr\u003e\n\n\n\u003cp\u003e\u003ca id=\"examples\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n# Examples\n\n[[back to top](#sections)]\n\nExamples for using the progress bar and percentage indicator objects can be found in the [IPython Demo Notebook](https://github.com/rasbt/pyprind/blob/master/examples/pyprind_demo.ipynb).\n\n\u003cp\u003e\u003ca id=\"contact\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasbt%2Fpyprind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frasbt%2Fpyprind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasbt%2Fpyprind/lists"}