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.

[BUG] printed text not showing up when using progress bar in jupyter-notebook

See original GitHub issue

Description: printed text not showing up when using progress bar in jupyter-notebook 2021-12-01 20-06-31

Provide a minimal code example that demonstrates the issue if you can. If the issue is visual in nature, consider posting a screenshot.

from time import sleep
from rich.progress import track

for i in track(range(1000)):
    sleep(1)
    print("Test, is it showing?")

Platform

OS: Linux env: jupyter-lab

I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.

pip freeze | grep rich

Output:

rich==10.15.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zhaowbcommented, Jan 1, 2022

It’s possible because jupyter lab version / ipywidgets installation not match:

If jupyter lab version is 1 or 2 (see doc), you’ll need manually install the extension. If jupyter lab version is 3 then it should be fine (doc is same page in above link).

To see if your jupyter lab is working as expected, please try this code

import time
from IPython.display import display as ipython_display
import ipywidgets
out1 = ipywidgets.Output()
out2 = ipywidgets.Output()
ipython_display(out1)
ipython_display(out2)
with out1:
    print('this is in out1')
print('outside context - where is this line ?')
with out2:
    print('this is out2')
print('outside context - where is this line *2 ?')
time.sleep(2)

with out1:
    print('more in out1')
time.sleep(1)
with out2:
    print('next in out2')
time.sleep(2)

with out1:
    out1.clear_output(wait=True)
    print('out1 is cleared, hope out2 is not')
time.sleep(2)

with out2:
    out2.clear_output(wait=True)
    print('out2 is cleared, hope out1 is not')

print('outside context - where is this line *3 ?')

It should have two output widgets being updated separately, meaning out1 and out2 are two different div and when out1 is cleared, out2 remains. When version/installation not correct, out1 and out2 outputs are intertwined and one clear will clear all.

I have tried in both jupyter lab 2 & 3 and see the version 3 works out of the box, and version 2 doesn’t work before install extention then works after installation.

Good luck

0reactions
github-actions[bot]commented, Jan 1, 2022

Did I solve your problem?

Consider sponsoring the ongoing work on Rich and Textual.

Or buy me a coffee to say thanks.

Will McGugan

Read more comments on GitHub >

github_iconTop Results From Across the Web

tqdm in Jupyter Notebook prints new progress bars repeatedly
Try using tqdm.notebook.tqdm instead of tqdm , as outlined here. This could be as simple as changing your import to: from tqdm.notebook ...
Read more >
TQDM progress bars in jupyter notebooks do not ... - GitHub
I have marked all applicable categories: exception-raising bug visual ... TQDM progress bars in jupyter notebooks do not appear in PDF via ...
Read more >
Progress bars in IPython Notebooks - fastai dev
The tqdm like progress bar is not appearing in my ipython notebook, however the same code when run on jupyter is shows the...
Read more >
A Complete Guide to Using Python Progress Bars - Built In
A progress bar in Python indicates whether the code is working or stuck in a loop due to an error. Here's how to...
Read more >
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 >

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