0

I use the following code to make the text colored: stopLoss = float(input(colored("Enter stop loss price> ", 'red'))). It works well wihtin Pycharm, but when I convert the python file to .exe file using pyinstaller, it outputs this: ←[31mEnter stop loss price> ←[0m20. What should I do?

bassel2777
  • 15
  • 5

2 Answers2

0

On windows you can use:

import os 

os.system('color 04') #red foreground color

color command syntax is: color *background* *foreground*

Here are the color codes

0 = Black 8 = Gray

1 = Blue 9 = Light Blue

2 = Green A = Light Green

3 = Aqua B = Light Aqua

4 = Red C = Light Red

5 = Purple D = Light Purple

6 = Yellow E = Light Yellow

7 = White F = Bright White

SEKTION
  • 87
  • 9
0

You can try colorama.

import colorama

colorama.init(True) # You dont need True, its so that you dont need to reset
# Text color after sending color all the time.

print(colorama.Fore.RED + "Hi!")

Would result in "Hi!" being printed as red color.

UPDATE:You also need to install it, you can do so by: pip install colorama (Might change from OS to OS.)