question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rich.progress.track to work in Juypter Notebooks

See original GitHub issue

Hey 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
leej11commented, Jul 10, 2020

Hi @willmcgugan just tried this out today.

image

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 either environment.yml or requirements.txt but it looks like you’re using poetry ?

image

Anyway, looks very nice!! Can’t wait to integrate it into some stuff.

1reaction
willmcgugancommented, Jul 9, 2020

Please give v3.1.0 a try which has progress support for Jupyter notebooks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Progress Display — Rich 12.6.0 documentation
Rich progress display supports multiple tasks, each with a bar and progress information. You can use this to track concurrent tasks where the...
Read more >
Extra output in progress bars running on jupyter notebooks.
Describe the bug I have a simple progressbar running in a jupyter notebook. from rich.progress import track for n in track(range(10), ...
Read more >
Progress bars with Rich - Will McGugan
It lets you render styled text and a whole bunch of other things (markdown, syntax, tables, tracebacks, etc.) to the terminal.
Read more >
How do I implement a progress bar - jupyter notebook
@EricHansen, try: from tqdm.auto import tqdm . It will try to automatically detect whether you are running in a notebook, or in a...
Read more >
Ever wanted Progress Bars in Jupyter? - Towards Data Science
The good news is you can create progress bars for Jupyter Notebooks with tqdm library. The library is incredibly easy to use and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found