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')
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?
Problem with termcolor module
python - Termcolor installs succesfully but doesn't seem to work properly - Stack Overflow
python - Why the termcolor doesn't work either the terminal supports coloring? - Stack Overflow
python - No module named 'termcolor' - Stack Overflow
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.
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"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:

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.
I'm trying to run an exploit written in Python that requires termcolor.py to be installed.
However, despite termcolor being installed in both Python and Python3, when I run the exploit, I always keep getting the error message "ImportError: No module named termcolor"
Does anyone know a solution to this please? This isn't the first exploit that have thrown this error, and judging by how many exploits that use termcolor for legibility purposes, I doubt this will be the last.
Thanks guys in advance!
I usually get these errors if I install in the wrong directory or run from the wrong directory or if I don't use sudo
$home : install apt pythonstuff.py $home: ls pythonstuff.py User $home: cd User $home/user: pythonstuff.py pythonstuff.py could not be found
Gotta go back to home and run it from there, as sudo
This can happen if you have multiple python 3 versions installed (due to apt-get upgrades).
To be sure it is installed to your current python 3 try:
python3 -m pip install termcolor
This is the correct way to ensure it is installed to the most current version, rather than:
pip3 install termcolor