rich.progress.track to work in Juypter Notebooks
See original GitHub issueHey thanks so much for this package! Just discovered it and have been playing around with it this morning.
I quite often work in JupyterLab / Jupyter Notebooks and most of the functionality seems to work and print fine as expected.
However, when trying to employ the rich.progress.track
functionality, or alternatively the rich.progress.Progress
class, I can’t get it to print the progress bar as output in the Jupyter Notebook.
So here’s the code I’ve been trying:
from rich.progress import track
import time
total = 0
def a_medium_speed_func(number):
time.sleep(0.5)
global total
total += number
for i in track(range(100), description="Processing..."):
a_medium_speed_func(i)
It’s a super dumb function but just made it to see the progress bar working.
I dug around and noticed a similar issue had been raised #26 and so I tried searching the docs and did find something that looked promising… rich.console.Console - force_jupyer so I tried the following code:
from rich.progress import track
from rich.console import Console
import time
console = Console(force_jupyter=True)
total = 0
def a_medium_speed_func(number):
time.sleep(0.5)
global total
total += number
for i in track(range(100), description="Processing...", console=console):
a_medium_speed_func(i)
But that still didn’t work. I’m not sure if it is something I am coding wrong, or perhaps there is missing functionality so I thought I’d raise this issue.
If there’s any more details you’d need from me let me know! I’m happy to help in whatever way I can.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7
Top GitHub Comments
Hi @willmcgugan just tried this out today.
First time I ran I got
ModuleNotFoundError: No module named 'ipywidgets'
, but after pip installing it worked perfectly. Does that mean ipywidgets needs to be added as a dependency I guess? I would attempt to offer a PR for that but I’m used to seeing eitherenvironment.yml
orrequirements.txt
but it looks like you’re usingpoetry
?Anyway, looks very nice!! Can’t wait to integrate it into some stuff.
Please give v3.1.0 a try which has progress support for Jupyter notebooks.