Search code examples
pythonchalk

Issue using pychalk


When I run

import chalk
print(chalk.red("test"))

on visual studio code, I am able to get the red "test" output as follows: https://gyazo.com/73473a3fbaf58bbca524232d5952c325

but when i run the code from cmd, the color is no displayed: https://gyazo.com/e75cbafd2485f5fbae1f194bf7d46c8b

what should i use to run the code in a client


Solution

  • This happens because Visual Studio Code emulates Linux terminal, while Windows Command line does not.

    Linux terminals and Windows command line use different escape sequences to display output.

    Here are some relevant StackOverflow questions:

    TL;DR: if you want a cross-platform solution, replace pychalk with something like colorama.

    Update: Once you understand the problem, you can also create an issue in the pychalk Github repository