[Tutor] Problem using termcolor and colorama

David Rock david at graniteweb.com
Thu Nov 15 12:08:32 EST 2018


> On Nov 15, 2018, at 07:18, John Blower <johnblower2016 at outlook.com> wrote:
> 
> I try to create colour text by using these two  modules , only returns the colour code, no colour text.
> How to solve this problem.
> 
>>>> import termcolor
>>>> import colorama
>>>> colorama.init()
>>>> termcolor.cprint('Hello World','red')
> [31mHello World[0m

I don’t know what those modules are, but based on the output, where you use them will matter.
Those are the correct ESC codes to print something in red, but your terminal needs to support displaying the colors.

If you are trying this in the python interpreter, try making a basic test script and run it instead to see if it works outside the interpreter environment.

I assume you are on Windows, too.  What OS and what version of Python are you using?

— 
David Rock
david at graniteweb.com






More information about the Tutor mailing list