Colorama for Python, Not returning colored print lines on Windows

前端 未结 7 1514
南笙
南笙 2020-12-01 18:16

I\'ve installed colorama for python. I\'ve imported the module as follows:

import colorama
from colorama import init
init()
from colorama import Fore, Back,          


        
相关标签:
7条回答
  • 2020-12-01 18:58

    I've never had success getting colors working in Windows cmd.exe without patching it with Ansicon. After patching, ANSI color codes will work without needing to use something like colorama (which didn't work for me either).

    To patch cmd.exe with Ansicon, do the following:

    1. Download Ansicon from https://github.com/adoxa/ansicon/downloads and unzip it into a directory with no spaces
    2. Use a cmd prompt and navigate to where you unzipped it.
    3. CD into the x64 directory (unless you have a 32bit machine, then use the x86 one)
    4. Type ansicon.exe –i
    5. Open a new cmd prompt

    via: https://stackoverflow.com/a/4749307/191902

    Also, if you have an NVidia graphics card, you might need to set the environment variable "ANSICON_EXC" to "nvd3d9wrap.dll".

    0 讨论(0)
提交回复
热议问题