Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows CMD - colors and Symbols are not displayed correctly #603

Closed
CarliJoy opened this issue Jan 20, 2021 · 18 comments · Fixed by #610
Closed

Windows CMD - colors and Symbols are not displayed correctly #603

CarliJoy opened this issue Jan 20, 2021 · 18 comments · Fixed by #610

Comments

@CarliJoy
Copy link

Describe the bug
Using Windows 10 colors and symbols are not displayed.

How to reproduce
Install pipx with Python 3.8 on Windows 10 like described in the documentation.
Use any pipx command with cmd.

Expected behavior
Symbol and Colors are displayed like in a bash shell.

What I currently get is:

2021-01-20_14h04_14

@uranusjr
Copy link
Member

Looks like there is an issue in your console configuration. Does color in other programs (e.g. pip) work?

@CarliJoy
Copy link
Author

Looks like there is an issue in your console configuration. Does color in other programs (e.g. pip) work?

Yep you're right:
https://superuser.com/questions/413073/windows-console-with-ansi-colors-handling/1050078#1050078
I have Windows 10 build 14393 - too old for ANSI support.

But coloring in pip actually works - no Idea how they do that:
2021-01-20_15h30_53

Also with pipenv it works like a charm without ANSI support.
2021-01-20_15h35_35

@uranusjr
Copy link
Member

Both pip and pipenv use colorama for colors, which is based on Windows API, not ANSI codes. Maybe pipx can use it as well.

With that said, I just noticed pipx’s code base actually turns all colors off on Windows, so those escape codes are likely not colors at all. I wonder where those come from. argcomplete?

@CarliJoy
Copy link
Author

CarliJoy commented Jan 21, 2021

With that said, I just noticed pipx’s code base actually turns all colors off on Windows, so those escape codes are likely not colors at all. I wonder where those come from. argcomplete?

Can I do something to find it out?
Currently don't have the time for debugging, sorry :(
Later maybe.

@itsayellow
Copy link
Contributor

itsayellow commented Jan 22, 2021

I think those may be the HIDE_CURSOR SHOW_CURSOR codes for shells.
https://github.com/pipxproject/pipx/blob/5c3cc823ab780f4d562e5e8c1ed0c31aee893133/src/pipx/animate.py#L12-L13

Possibly we need to avoid them in Windows.

@uranusjr
Copy link
Member

Or use a platform-specific solution on Windows? There are Windows APIs for this: https://stackoverflow.com/a/10455937/1376863

@itsayellow
Copy link
Contributor

I always am annoyed with Windows because there are so many different shells, and they all seem to behave differently, especially when trying to do anything more than print text. I wonder if the solution in the stackoverflow link works for all the shells people use.

@itsayellow
Copy link
Contributor

I suppose to truly fix this we should investigate something like colorama and cursor.

And then somebody would have to try it in every Windows shell to see which one(s) it fails in 😉

@CarliJoy
Copy link
Author

And then somebody would have to try it in every Windows shell to see which one(s) it fails in wink

I could offer to test

  • Windows CMD
  • Integrated Terminal in PyCharm
  • GIT Bash (in Windows)
  • Maybe Powershell

-> actually I don't know more ;-)

@itsayellow
Copy link
Contributor

@CarliJoy, could you test the linked PR and see if it stops printing cryptic characters in your Windows shells?

@CarliJoy
Copy link
Author

With --version it works.
But during install they are still there:

2021-01-24_16h16_57

@itsayellow
Copy link
Contributor

itsayellow commented Jan 24, 2021

Hmm, ok. Does the released pipx version fail the same way for pipx install? Or is this a regression with this PR?
Never mind, I see it in your original post.

OK, so those characters must be from something else, but at least some of the issue has been fixed.

@itsayellow
Copy link
Contributor

Ah got it! \033[K is the ANSI code for "clear line" which we use for animation. OK, that's something else to fix.

@itsayellow
Copy link
Contributor

It looks like \033[K will be translated correctly with the fix in #612

@itsayellow
Copy link
Contributor

Thanks for your help testing @CarliJoy .

@CarliJoy
Copy link
Author

shall I test your fix in #612 again?
Thanks for writing the code 👍

@itsayellow
Copy link
Contributor

If you have some time testing #612 would be great. For #612 you will still see [?25l and [?25h but it should fix the animation problems with pipx install. (If it doesn't, it would be good to know!)

@CarliJoy
Copy link
Author

Double Posting from #612

Current Result on Windows:

2021-01-27_14h51_03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants