Poetry: No colors in Windows Terminal or cmd

Created on 4 Feb 2020  路  8Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10.0.18362.592
  • Poetry version: 1.0.3
  • Link of a Gist with the contents of your pyproject.toml file: n/a

Issue

This is https://github.com/python-poetry/poetry/issues/548 which was said to be fixed in "the latest beta" at the time, but now appears to be broken with no beta being more recent than the latest released version (1.0.3).

Long story short, there are no colors displayed on windows with any of the command shells I tried except in ConEmu. The default cmd.exe, powershell.exe and the new Windows Terminal don't display colors.

Some screenshots:

Powershell in Windows Terminal:

image

Cmd in Windows Terminal:

image

cmd.exe:

image

Cmd in Cmder (based on ConEmu) - This works!:

image

Powershell in Cmder (based on ConEmu):

image

This last one can probably be considered working as well, the green text is likely due to the cmder config.

Bug CLI

Most helpful comment

I found the problem here. Poetry uses cleo which in turn uses clikit which in turn uses pastel. Where pastel doesn't support colours on Windows. The alternative is to use colorama, for colour.

All 8 comments

@sztomi Did you also noticed that in Cmder at least as soon as I hit $poetry shell that all colors disappear & emacs key binding on the shell is gone as well? Have you found a fix for that or should I put in as second bug list?
Plus, do you get different prompt? Mine is plain C:\Prj\MOA> instead of what I see with pyenv:

C:\Prj  
位 v_awscli.bat
C:\Users\ny11559\.pyenv\pyenv-win\versions\aws_cli\Scripts\activate
C:\Prj  
(aws_cli) 位 

I know that this is supposed to be depreciated with PYENV_VIRTUALENV_DISABLE_PROMPT=1, but I will likely keep it as is.
Thanks,

I tried with poetry --ansi and it worked for me. Seems like some stdout coloring library disables ANSI output when detecting PowerShell, and that --ansi forces it.

Looks like using rich would solve this issue.

I can't display the ANSI color effect in Windows terminal either, I have to add the command line parameter --ansi every time I run it, can this option switch be added to the config without adding the parameter every time?

@myliyifei you could use an alias (sth. like alias poetry="poetry --ansi") as a workaround, but I don't know how to make aliases on windows though (or if it's even possible at all...)

@sztomi hi ,you can check the env, the poety need to get your "TERM"

echo $TERM

For TERM = cygwin , you need to add --ansi to focus color it.
For TERM = xterm, you are lucky.
I'm not clear the other values.

What is yours ?
here is my config.
powershell_to_msys2

@gaoming714 TERM is not set in native windows terminals, that's a unix thing.

I found the problem here. Poetry uses cleo which in turn uses clikit which in turn uses pastel. Where pastel doesn't support colours on Windows. The alternative is to use colorama, for colour.

Was this page helpful?
0 / 5 - 0 ratings