To make the ANSI colors used in termcolor work with the windows terminal, you'll need to also import/init colorama;
>>> from termcolor import *
>>> cprint('hello', 'red')
←[31mhello←[0m
>>> import colorama
>>> colorama.init()
>>> cprint('hello', 'red')
hello <-- in red color
>>>
Answer from Joachim Isaksson on Stack OverflowTo make the ANSI colors used in termcolor work with the windows terminal, you'll need to also import/init colorama;
>>> from termcolor import *
>>> cprint('hello', 'red')
←[31mhello←[0m
>>> import colorama
>>> colorama.init()
>>> cprint('hello', 'red')
hello <-- in red color
>>>
windows command prompt uses a command to change the terminal output colour. you can execute the command 'color color-code' to change the color instantly. Just having the command color activates this color feature.
In short.. For your script to work, Run this at the start of your script.
import os
os.system('color')
Newest 'termcolor' Questions - Stack Overflow
python - No module named 'termcolor' - Stack Overflow
python - cprint (termcolor) does not print in color - Stack Overflow
TermColor not working in python 3.6
See this stackOverflow post.
It basically says that in order to get the escape sequences working in Windows, you need to run os.system('color') first.
For example:
import termcolor
import os
os.system('color')
print(termcolor.colored("Stack Overflow", "green")
termcolor or colored works perfectly fine under python 2.7 and I can't replicate your error on my Mac/Linux.
If you looks into the source code of colored, it basically print the string in the format as
\033[%dm%s\033[0m' % (COLORS[color], text)
Somehow your terminal environment does not recognise the non-printing escape sequences that is used in the unix/linux system for setting the foreground color of xterm.
My guess is that you probably have two versions of Python or downloaded the wrong module.
1)Wrong Module:
pip install term color
It will install a different module. To fix it, install the correct module:
pip install termcolor
2)Two-Versions
If you have two versions of Python, you need to specify it:
i)Two versions of Python 3:
If you two versions of Python3, specify:
pip3.x install termcolor
ii)If you have Python 2 installed:
If you have Python 2 and 3 installed, specify it, as pip works for Python2, and pip3 works for Python 3:
pip3 install termcolor
If you have only Python3, or in simple words only one version of Python, You can follow the first instruction.
The simplest way, if you already have termcolor installed to Python3.x and it still has problems when you use programs with #!/usr/bin/env python, is to just copy the termcolor.py file from /usr/lib/python3/dist-packages to /usr/lib/python2.x
Seriously, that's it. No dependencies. Just copy and go.
Hi, I used the pip install and pip3.6 install and successfully installed the module on both pythons.
When I run the print colorered on python 2 it works fine, but in 3.6 it doesn't
At first I thought it was a module issue, but the module is definitely installed.
Does this just not work on python 3.6?
As You can see run output is not rendering colors. I do not have this problem with VSC. Can anyone help me with this one? I tried "Emulate terminal in output in console" and i receive this: ←[32mtest test test test←[0m
No colors in "test test test test"import sys
from termcolor import colored, cprint
cprint('HELLO','red')Thats my code but when i run this its prints this instead of getting red colour
[31mHELLO[0m
I am using python 3.8.5 on windows 8.1 Pro
try this code in print:
print(colored(f"[{i}]", 'blue','on_white',['blink'],force_color='True'), end=end)
If you have the desired effect in cmd prompt, but not in pyCharm. Look at the picture and see if it helps. This should work for all pyCharm versions 2023.#.# and up
Edit Configurations to emulate terminal in output console:

Using Colorama to make Termcolor work in Windows:
This is where I got the reference from :REFERENCE
from colorama import init
from termcolor import cprint
init()
#colored() will also work
cprint("Hello World test","cyan")
#hit enter to exit
input()
Try to fix it by installing colorama package:
pip install colorama
Source.