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] Flashing Progress Bars (Colorama?)

See original GitHub issue

Describe the bug When I utilize functions/classes within the pyNastran library, my progress bars start flashing and lose the bar color. pyNastran seems to use a custom logger written by @SteveDoyle2, which uses Colorama. I suspect thereโ€™s some clash with the built-in logging from PyNastran, and the colors my own code uses from Rich.

To Reproduce From the docs and slightly expanded:

from rich.progress import track
import time

for n in track(range(20), description="Processing..."):
    time.sleep(0.5)

Now with just a BDF object from the pyNastran library instantiated, do exactly the same thing:

from rich.progress import track
import time
from pyNastran.bdf.bdf import BDF

_ = BDF()

for n in track(range(20), description="Processing..."):
    time.sleep(0.25)

Color goes away until itโ€™s completed, and with more complex progress trackers the spinners/time columns seem to flash.

Platform What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

Windows 10. Windows Terminal (calling cmd.exe). Python 3.8.5. Rich 10.1.0

Diagnose

python -m rich.diagnose
python -m rich._windows
pip freeze | grep rich
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ <class 'rich.console.Console'> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ A high level console interface.                                                  โ”‚
โ”‚                                                                                  โ”‚
โ”‚ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ โ”‚
โ”‚ โ”‚ <console width=132 ColorSystem.TRUECOLOR>                                    โ”‚ โ”‚
โ”‚ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ โ”‚
โ”‚                                                                                  โ”‚
โ”‚     color_system = 'truecolor'                                                   โ”‚
โ”‚         encoding = 'utf-8'                                                       โ”‚
โ”‚             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ”‚
โ”‚           height = 61                                                            โ”‚
โ”‚    is_alt_screen = False                                                         โ”‚
โ”‚ is_dumb_terminal = False                                                         โ”‚
โ”‚   is_interactive = True                                                          โ”‚
โ”‚       is_jupyter = False                                                         โ”‚
โ”‚      is_terminal = True                                                          โ”‚
โ”‚   legacy_windows = False                                                         โ”‚
โ”‚         no_color = False                                                         โ”‚
โ”‚          options = ConsoleOptions(                                               โ”‚
โ”‚                        size=ConsoleDimensions(width=132, height=61),             โ”‚
โ”‚                        legacy_windows=False,                                     โ”‚
โ”‚                        min_width=1,                                              โ”‚
โ”‚                        max_width=132,                                            โ”‚
โ”‚                        is_terminal=True,                                         โ”‚
โ”‚                        encoding='utf-8',                                         โ”‚
โ”‚                        justify=None,                                             โ”‚
โ”‚                        overflow=None,                                            โ”‚
โ”‚                        no_wrap=False,                                            โ”‚
โ”‚                        highlight=None,                                           โ”‚
โ”‚                        markup=None,                                              โ”‚
โ”‚                        height=None                                               โ”‚
โ”‚                    )                                                             โ”‚
โ”‚            quiet = False                                                         โ”‚
โ”‚           record = False                                                         โ”‚
โ”‚         safe_box = True                                                          โ”‚
โ”‚             size = ConsoleDimensions(width=132, height=61)                       โ”‚
โ”‚        soft_wrap = False                                                         โ”‚
โ”‚           stderr = False                                                         โ”‚
โ”‚            style = None                                                          โ”‚
โ”‚         tab_size = 8                                                             โ”‚
โ”‚            width = 132                                                           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
platform="Windows"
WindowsConsoleFeatures(vt=True, truecolor=True)

(I donโ€™t have grep or cygWin/gitBash installed at all)

'grep' is not recognized as an internal or external command,
operable program or batch file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
Czarifiedcommented, Aug 31, 2021

@willmcgugan That seems to fix it!

Conclusion: If any code or imported libraries use Colorama, it can cause graphical glitches with colors, spinners, and progress bars. If you know you have this โ€œconflictโ€ add the following to your imports section:

import colorama
colorama.deinit()

Thanks so much Will and Steven for your help here! Iโ€™ll close this issue.

1reaction
SteveDoyle2commented, Aug 31, 2021

Iโ€™ve never tried rich outside of my quick test today, so Iโ€™m not sure how rich is supposed to look, but I think itโ€™s due to the difference in how we call colorinit. I use autoreset=True in cpylog (imported by pyNastran) and rich uses strip=False and theyโ€™re both called.

The behavior under powershell seems strange (the line changing after itโ€™s done), but thatโ€™s consistently weird. Terminal changes the color of the line during runtime based on the init flags.

Thereโ€™s probably an update init call that needs to be done, that probably should be handled externally from either package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Flickering large progress display on Alacritty #2139
Describe the bug I have a progress bar that sometimes has up to 20 items, and it flickers kind of annoyingly.
Read more >
AE 6 Colorama Output Cycle bug?
Solved: I'm trying to use the AE 6 Colorama Output Cycle effect. I selected the preset Hue Cycle. The problem is the only...
Read more >
Why does the text on my asynchronous ProgressBar flicker?
Your current problem is that the bar is repainting itself every time you change the value, thus the flickering of the text. If...
Read more >
How can I stop Progress bar blinking
Hello All,. I have a SQL table with more than 2000 records, When I search the table with PowerShell the progress bar continue...
Read more >
Utilities โ€” Click Documentation (8.1.x)
On Windows, Click uses colorama without calling colorama.init() . ... Click will then automatically print a progress bar to the terminal and calculate...
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