Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Rich library with Jupyter Notebooks in VSCode generates new Output Cells for each individual output #3483

Open
Amodh1257 opened this issue Sep 8, 2024 · 1 comment

Comments

@Amodh1257
Copy link

Amodh1257 commented Sep 8, 2024

Hi all,
I couldn't find anyone talking about this anywhere else online, so I decided to post this here as a potential bug. Not quite sure what is going wrong, could even be a problem with my setup specifically.
I'm running a .ipynb Jupyter Notebook on VSCode with the standard Jupyter extension pack provided by Microsoft.

Printing an normal output works fine, but when I import and use anything from the rich library (progress bar, rich print etc.), every subsequent line printed to the notebook generates a new output cell.

image

When you print a ton of stuff in one cell, notebooks limit how many lines you can see at once and adds a scrollbar. This feature doesn't work when every printed line is in its own output cell and makes reading outputs and scrolling through notebooks extremely tedious.

This isn't an issue when executing similar code in google colab, so I believe it to be a problem native to VSCode's inbuilt notebook output renderer. This is the renderer I am currently using: the only other one natively provided being text/plain, which doesn't render many rich elements (such as progress bars) at all.
image
I have scoured the web for better Jupyter notebook output renderers to no avail. If there is one that works better for rich, please let me know!

Not sure how to fix this if it is an issue on my end, gave it a bunch of tries to no avail. Any help would be wonderful. Thanks!
Edit: Wanted to add that one such fix I tried was using the rich.jupyter library. Unfortunately, the print statement from there causes the exact same issue as well.

P.S. I'm new to github in general and a novice coder so forgive me if the report is crude or dated or if there is something I missed.

Platform Information

Click to expand
# Results from....
from rich.diagnose import report
report()
# ....printed below
╭──────────────────────── <class 'rich.console.Console'> ────────────────────────╮
│ A high level console interface.                                                │
│                                                                                │
│ ╭────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=115 ColorSystem.TRUECOLOR>                                  │ │
│ ╰────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                │
│     color_system = 'truecolor'                                                 │
│         encoding = 'utf-8'                                                     │
│             file = <ipykernel.iostream.OutStream object at 0x0000021EFD33BD60> │
│           height = 100                                                         │
│    is_alt_screen = False                                                       │
│ is_dumb_terminal = False                                                       │
│   is_interactive = False                                                       │
│       is_jupyter = True                                                        │
│      is_terminal = False                                                       │
│   legacy_windows = False                                                       │
│         no_color = False                                                       │
│          options = ConsoleOptions(                                             │
│                        size=ConsoleDimensions(width=115, height=100),          │
│                        legacy_windows=False,                                   │
│                        min_width=1,                                            │
│                        max_width=115,                                          │
│                        is_terminal=False,                                      │
│                        encoding='utf-8',                                       │
│                        max_height=100,                                         │
│                        justify=None,                                           │
│                        overflow=None,                                          │
│                        no_wrap=False,                                          │
│                        highlight=None,                                         │
│                        markup=None,                                            │
│                        height=None                                             │
│                    )                                                           │
│            quiet = False                                                       │
│           record = False                                                       │
│         safe_box = True                                                        │
│             size = ConsoleDimensions(width=115, height=100)                    │
│        soft_wrap = False                                                       │
│           stderr = False                                                       │
│            style = None                                                        │
│         tab_size = 8                                                           │
│            width = 115                                                         │
╰────────────────────────────────────────────────────────────────────────────────╯


╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯


╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-color',         │
│     'COLORTERM': None,             │
│     'CLICOLOR': '1',               │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': None,          │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯


platform="Windows"
Copy link

github-actions bot commented Sep 8, 2024

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@Amodh1257 Amodh1257 changed the title [BUG] [BUG] Rich library with Jupyter Notebooks in VSCode generates new Output cells for each individual output Sep 8, 2024
@Amodh1257 Amodh1257 changed the title [BUG] Rich library with Jupyter Notebooks in VSCode generates new Output cells for each individual output [BUG] Rich library with Jupyter Notebooks in VSCode generates new Output Cells for each individual output Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant