Search code examples
pythonpython-3.xtermcolor

Termcolor seems to be working in IDE but not in CMD


from termcolor import colored, cprint

cprint("TESTING TERMCOLOR", "red")

This code is working in my IDE (Pycharm) but not on my terminal. Gives coloured output in IDE but not in terminal. This is the Output in terminal:

[31mTESTING TERMCOLOR[0m


Solution

  • If by cmd you mean the standard windows terminal, I fear termcolor does not work out of the box there. See e.g. Why does termcolor not work in python27 windows? or Why does termcolor output control characters instead of colored text in the Windows console?. https://github.com/tartley/colorama seems to be a workaround to make it work there