Closed rookiebulls closed 4 years ago
Could you please paste your code and elaborate on the environment you use (which terminal, etc)
@caizixian I am using cmd.exe on Windows 7, just some test code in the python shell.
>>>import crayons
>>>print crayons.red('this is red')
>>>here output some ANSI code
>>>import colorama
>>>colorama.init()
>>>print crayons.red('this is red')
>>>now it output some red color text
Please see the image below.
cmd.exe of Windows 7 doesn't support ANSI escape sequences.
This topic on superuser might helps if you want these be intepreted by cmd.exe natively http://superuser.com/questions/413073/windows-console-with-ansi-colors-handling/
So pure crayons might not works under cmd.exe of Windows 7.
However according to the documentation of colorama
This has the upshot of providing a simple cross-platform API for printing colored terminal text from Python, and has the happy side-effect that existing applications or libraries which use ANSI sequences to produce colored output on Linux or Macs can now also work on Windows, simply by calling
colorama.init()
.
Yes, calling colorama.init()
will convert subsequent ANSI sequences to corresponding win32 calls, and therefore make crayons work again.
@kennethreitz any idea on this?
This was fixed with #12.
I have to use colorama to "init" before using crayons to output some colored text on windows, otherwise the console just output some ANSI code, without any color.