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 122 times
0
-
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
2 Answers
1
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
- 169
- 1
- 12
0
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
- 353
- 1
- 7