rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

alive_bar in Jupyter needs force_tty #178

Closed Miladiouss closed 2 years ago

Miladiouss commented 2 years ago

The alive bar does not show during Jupyter cell process and only outputs the final frame:

from alive_progress import alive_bar
from time import sleep

x = list(range(50))
with alive_bar(len(x), title='Jupyter Alive Progress Bar:') as bar:
    for i in x:
        sleep(.1)
        bar()
Jupyter Alive Progress Bar: |████████████████████████████████████████| 50/50 [100%] in 5.0s (9.98/s) 

Things work properly in my terminal.

Here is my system configuration if needed:

rsalmei commented 2 years ago

Well, if there was that output, it seems to be working to me. What did happen?

Miladiouss commented 2 years ago

There is no progress bar. After the cell is finished, the output above is printed, with that warning sign emoji (⚠︎). I updated my previous post.

TheTechRobo commented 2 years ago

You need to show your code. Generally when there's the warning sign and 0%, it's because you forgot to increment the bar.

rsalmei commented 2 years ago

Exactly what @TheTechRobo said, thanks. And, if it appears only after ending, this is intended behavior, since the jupyter does not report itself as interactive. You have to use force_tty=True.

Please show your code, then we would not have to be figuring things out by ourselves.

Miladiouss commented 2 years ago

Thank you @TheTechRobo. As your suggestion, providing the force_tty=True corrects the behavior :+1:

from alive_progress import alive_bar
from time import sleep

x = list(range(50))
with alive_bar(len(x), title='Jupyter Alive Progress Bar:', force_tty=True) as bar:
    for i in x:
        sleep(.1)
        bar()
rsalmei commented 2 years ago

You're welcome!