0

I am trying to get a portion of my code to print out in color using colorama. I have:

from colorama import init, Fore, Style
init(convert=True)
print(Fore.RED + 'Hello')

but the code output has no color change. What am I doing wrong?

eyllanesc
  • 190,383
  • 15
  • 87
  • 142
Andrea
  • 43
  • 7
  • What console are you using? Does it support ANSI codes for coloring? – Adam Smith Feb 19 '19 at 05:39
  • @AdamSmith I am honestly not sure.. I am very new to this. I am in IDLE right now for 3.7.2 which is where my file is. – Andrea Feb 19 '19 at 07:07
  • Just tried this code in window 10 default terminal, and it is running file, in spider it is not working as expected, in pycharm terminal it is working , in pycharm python console it is not working – sahasrara62 Feb 19 '19 at 07:44
  • @Andrea it sounds like your code is working fine, but IDLE does not support ANSI color codes. Terminals are a whole kettle of worms that's way out of scope here. – Adam Smith Feb 19 '19 at 08:28
  • @AdamSmith Oh, okay thank you, I did not know that. Is there anyway I can print colored text from a file in IDLE (IDLE is required by my course). – Andrea Feb 19 '19 at 18:40
  • You can try https://stackoverflow.com/questions/42472958/how-do-i-print-colored-text-in-idles-terminal but it sounds like you're doing the right thing and shouldn't worry about trying to get it to work in IDLE. IDLE isn't the best IDE (by a long shot) though it's better in recent years. – Adam Smith Feb 19 '19 at 19:23
  • @AdamSmith, okay, thank you! – Andrea Feb 19 '19 at 22:49

1 Answers1

0

It works without init(convert=True). you should use init()

from colorama import init, Fore, Style
init()
print(Fore.RED + 'Hello')