Search code examples
pythoncolorstermcolorfiglet

How can I print colored pyfiglet text in windows cmd


Hello so I am using Python and I want to print out the name of the program with color while using figlet_format so I got it working fine in vscode but when I try to run the file in cmd it prints this:

[34m _   _      _ _
| | | | ___| | | ___
| |_| |/ _ \ | |/ _ \
|  _  |  __/ | | (_) |
|_| |_|\___|_|_|\___/

[0m

insted of printing what it prints in vscode:

enter image description here

So I was wondering if there is a way to print color in cmd while using pyfiglet, this is my code:

from termcolor import colored
from pyfiglet import figlet_format

print((colored(figlet_format("Hello"), color="blue")))

Solution

  • On Windows, you need to install Colorama.

    Makes ANSI escape character sequences (for producing colored terminal text and cursor positioning) work under MS Windows.