Python Forum
Coloured text in the terminal works in Linux but not Windows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coloured text in the terminal works in Linux but not Windows
#1
I'm using the syntax "\033[31;40mRed\033[37;40m" for coloring text in the terminal, and it works perfectly on my Linux laptop, but when I installed Python on my Windows PC and tried running my code, the color syntax just printed as-is. Is there another module I have to install for it to work on Windows?
Reply
#2
That ANSI escape sequences are going to work on terminals under linux, not Windows command prompt. I dont think the default windows prompt supports escape sequences, but i could be wrong. For windows, people usually use a library such as colorama.

You could also install either Cmder, ConEmu, ANSICON or Mintty (used by default in GitBash and Cygwin) to add coloring support to your Windows command console with escape sequences
Recommended Tutorials:
Reply
#3
Thanks for the info! I'll have to check those out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,277 May-24-2022, 07:02 AM
Last Post: netanelst
  Resources for printing tabledata-Linux and Windows hammer 4 1,390 Apr-25-2022, 12:09 PM
Last Post: hammer
  How to link Sublime Text 3 Build system to Python 3.9 Using Windows 10 Fanman001 2 4,531 Mar-04-2021, 03:09 PM
Last Post: martpogs
  multiprocessing difference between Linux and Windows direl 2 2,593 Oct-01-2020, 07:10 PM
Last Post: direl
  read terminal text from running program AArdvark_UK 2 1,853 Aug-27-2020, 12:43 PM
Last Post: AArdvark_UK
  script works in windows but not in linux ovidius80 2 2,679 Apr-29-2020, 02:10 PM
Last Post: ovidius80
  keyboad scanner routine(linux and windows) 1885 0 1,880 Oct-26-2019, 03:34 PM
Last Post: 1885
  Code works in IDLE, appears to work in CMD, but won't produce files in CMD/Windows ChrisPy33 3 3,195 Jun-12-2019, 05:56 AM
Last Post: ChrisPy33
  Run .py file in Kali Linux Terminal grayarea3 4 28,312 Feb-27-2019, 06:51 PM
Last Post: buran
  colorama/termcolor not returning coloured lines kapilan15 3 6,712 Jan-14-2019, 12:57 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020