tqdm progressbar and colorama do not work together

荒凉一梦 提交于 2019-12-07 08:57:14

问题


I want to use colorama, but I already use tqdm in my code.

Example:

import colorama as color
import tqdm as tqdm  # without line it's working
print(color.Fore.GREEN + 'Green text')

It's working fine without tqdm, but if I import tqdm, colorama does not color the text until I restart the console. I use IPython console with Spyder (Python 3.6).

Is there a way I can use these packages together?


回答1:


try it as follow (https://github.com/tqdm/tqdm/issues/450)

from tqdm import trange
from colorama import Fore
for i in trange(int(7e7),
    bar_format="{l_bar}%s{bar}%s{r_bar}" % (Fore.GREEN, Fore.RESET)):
    pass


来源:https://stackoverflow.com/questions/43097262/tqdm-progressbar-and-colorama-do-not-work-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!