Progress bar in python

Progress bar in python

Have you ever executed a program that takes so much time that you almost thought that your PC got hang while executing it.?

If yes, now you can use a progress bar to track the progression of your program and get live feedback of how much the program is executed and how much time is left for its completion AKA ETA.

There are many python libraries that can be used to enable progress bar functionality in python. below are some of the best, feature-rich libraries you can use to add a progress bar in your next python program.

Benefits of using a progress bar:

  • It gives a visual feedback of the process’s progress.
  • An extimation of the time left for the program to complete execution.
  • Indication if the Console is hang or the program, it got stuck while executing.

Alive-Progress

alive-progress spinners
Alive Python

By far the most comprehensive and cool-looking progress bar which anybody would fall for because of its great visuals. The unique loading bar styles surely do a great job of keeping you entertained while your PC is doing the processing.

You can check download and check the library on Alive- Progress on Github.

You can simply install alive python using pip by executing the command

pip install alive-python

pip install alive-python

After installing you can run the demo by executing the command. P.S. it is really addictive to watch it progress in different styles.

python -m alive_progress.tools.demo

You can explore and learn more on how to integrate the progress bar in your code by reading the documentation on Alive-python github. It has fairly good documentation with use cases and codes snippets to guide you on how to use implement different progress bar styles.

Progressbar2

Python-Progressbar (also known as Progressbar2) is a popular and simple to use package. It has several really useful functions, such as auto-resizing when the system allows it. In the form of widgets such as AbsoluteETA, AdaptiveETA, and others, you may alter the format of the progress bar.

you can install the package using pip

pip install progressbar2

TO start with you can run this sample code snippet.

from time import sleep
from progressbar import progressbar

for i in progressbar(range(100)):
    sleep(0.02)

For more details check progressbar2 github .

Tqdm

TQDM is the most simple progress bar which you can easily integrate in you code.

I was surprised to know that tqdm is derived from the word “taqaddum” which is Arabic for “progress’ and is also a abbreviation for “te quiero demasiado” which means “I love you so much” in spanish.

you can install tqdm using pip.

pip install tqdm
Screenshot
tqdm demo

you can find more indepth documentation on the features of tqdm on the tqdm github page .


Thank you for reading, Happy Learning, drop your suggestion in the comments.

Feel free to follow us on Youtube, Linked In , Instagram

Loading comments...
Mastodon