I find the new version pip(package installer for Python) has a colorful progress bar to show the downloading progress. How can I do that?
Asked
Active
Viewed 2,773 times
5
-
https://stackoverflow.com/questions/58328625/tqdm-colored-progress-bar-printing-on-multiple-lines – 404pio Apr 19 '22 at 10:51
-
https://stackoverflow.com/questions/287871/how-do-i-print-colored-text-to-the-terminal-in-python – 404pio Apr 19 '22 at 10:52
-
@404pio, it's cool, but I want a more fancy bar like the pip has :D. Thanks anyway – PinkR1ver Apr 19 '22 at 10:53
3 Answers
10
pip itself is using the rich package! In particular, their progress bar docs show this example:
from rich.progress import track
for n in track(range(n), description="Processing..."):
do_work(n)

Lucas Saldyt
- 359
- 2
- 13
3
import time
from rich.progress import track
for n in track(range(20), description="Processing..."):
time.sleep(n)
Rich is installed with latest pip, but incase you are missing it:
pip install rich

ckloan
- 154
- 1
- 8
1
The following simple code uses pip own progress bar controls.
import time
from pip._internal.cli.progress_bars import get_download_progress_renderer
if __name__ == "__main__":
chunks = []
b = get_download_progress_renderer(bar_type="on",size=100)
for i in range(100):
chunks.append(range(i))
for bb in b(chunks):
time.sleep(.1)

Hezi Shahmoon
- 388
- 1
- 7