python - Print colorized output - working from console but not from script -
i have weird problem cannot set finger on. there programme utilize (and contribute time time) has colorized console output. worked great until reinstalled windows. cannot colorized output.
this script used colorizing.
i have managed narrow downwards problem to, more or less, simple situation, have no thought wrong.
this console prompt works expected (string test
printed in red):
python 2.7.3 (default, apr 10 2012, 23:24:47) [msc v.1500 64 bit (amd64)] on win32 type "help", "copyright", "credits" or "license" more information. >>> import sys >>> sys.path.insert(0, r'c:\bin\sv\tea\src') >>> tea.console.color import cprint, color >>> cprint('test\n', color.red) test >>>
but when run next script same version of python output test
not in reddish color (there no color, default console color):
import sys sys.path.insert(0, r'c:\bin\sv\tea\src') tea.console.color import cprint, color cprint('test\n', color.red)
the same setup worked before reinstalled system. i have checked, environment variables in interactive mode , script same. i have tried in standard windows command prompt , console, programme use. os in question windows 8 , before reinstall used on windows 8. same code same setup works @ computer @ work (windows 7). i have python 2.7 , python 3.3 installed (as did before). have tried run script calling python interpreter straight (c:\python27\python.exe
) or py -2
, not help. ipython , mercurial colorizes output should. any ideas can seek create work?
edit:
maybe not clear, script utilize colorize output given in link in question. here 1 time again: https://bitbucket.org/alefnula/tea/src/dc14009a19d66f92463549332a321b29c71d47b8/src/tea/console/color.py?at=default
i have found problem , solution.
i believe problem bug in x64 ctypes module. had python 2.7 x64 installed , version next line (from script linked in question):
ctypes.windll.kernel32.setconsoletextattribute(std_out_handle, code)
returns error code 6 description the handle invalid
. after investigation, deduced problem might x64 version of python, installed 32-bit version , works expected.
since solves problem, , not have time deeper analysis leave @ this, wanted give kind of resolution question.
python windows console
No comments:
Post a Comment