[BUG] Colors doesn't work on Git Bash
See original GitHub issueDescribe the bug I am Windows 7 and install python 3.8 where I used Git Bash(For a change.). I typed the following things in terminal where it should show the image as in ReadMe. While I get a long error Message of UnicodeEncodeError The output I get is
Rich features
Colors 256 colors or 16.7 million colors (if supported by your
terminal).
Styles All ansi styles: bold, dim, italic, underline,
strikethrough, reverse, and even blink.
Text Word wrap text. Justify left, center, right or full.
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
dolor sit dolor sit dolor sit dolor sit
amet, amet, amet, amet,
consectetur consectetur consectetur consectetur
adipiscing adipiscing adipiscing adipiscing
elit. Quisque elit. Quisque elit. Quisque elit. Quisque
in metus sed in metus sed in metus sed in metus sed
sapien sapien sapien sapien
ultricies ultricies ultricies ultricies
pretium a at pretium a at pretium a at pretium a at
justo. justo. justo. justo.
Maecenas Maecenas Maecenas Maecenas
luctus velit luctus velit luctus velit luctus velit
et auctor et auctor et auctor et auctor
maximus. maximus. maximus. Donec maximus. Donec
Donec Donec faucibus vel faucibus vel
faucibus vel faucibus vel arcu id arcu id
arcu id arcu id pretium. pretium.
pretium. pretium.
CJK support Traceback (most recent call last):
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\__main__.py", line 188, in <module>
print(line)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 41, in write
self.__convertor.write(text)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 162, in write
self.write_and_convert(text)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 187, in write_and_convert
self.write_plain_text(text, cursor, start)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
self.wrapped.write(text[start:end])
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-31: character maps to <undefined>
and no colours in it.
Also, when I run py -m rich.logging
I get a ZeroDivisionError.
[17:18:29] INFO Server starting... logging.py:155
INFO Listening on http://127.0.0.1:8080 logging.py:156
[17:18:30] INFO GET /index.html 200 1298 logging.py:159
INFO GET /imgs/backgrounds/back1.jpg 200 54386 logging.py:160
INFO GET /css/styles.css 200 54386 logging.py:161
WARNING GET /favicon.ico 404 242 logging.py:162
[17:18:31] DEBUG JSONRPC request logging.py:165
--> {'version': '1.1', 'method':
'confirmFruitPurchase', 'params': [['apple',
'orange', 'mangoes', 'pomelo'], 1.123],
'id': '194521489'}
<-- {'version': '1.1', 'result': True,
'error': None, 'id': '194521489'}
DEBUG Loading configuration file /adasd/asdasd/qeq logging.py:175
we/qwrqwrqwr/sdgsdgsdg/werwerwer/dfgerert/er
tertert/ertetert/werwerwer
ERROR Unable to find 'pomelo' in database! logging.py:178
INFO POST /jsonrpc/ 200 65532 logging.py:179
INFO POST /admin/ 401 42234 logging.py:180
WARNING password was rejected for admin site. logging.py:181
ERROR An error of some kind occurred! logging.py:185
Traceback (most recent call last):
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\logging.py", line 183, in <module>
1 / 0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\logging.py", line 185, in <module>
log.exception("An error of some kind occurred!")
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1469, in exception
self.error(msg, *args, exc_info=exc_info, **kwargs)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1463, in error
self._log(ERROR, msg, args, **kwargs)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1577, in _log
self.handle(record)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1587, in handle
self.callHandlers(record)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1649, in callHandlers
hdlr.handle(record)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 950, in handle
self.emit(record)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\logging.py", line 128, in emit
self.console.print(
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\console.py", line 1028, in print
self._buffer.extend(new_segments)
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\console.py", line 507, in __exit__
self._exit_buffer()
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\console.py", line 485, in _exit_buffer
self._check_buffer()
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\site-packages\rich\console.py", line 1156, in _check_buffer
write(line)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 41, in write
self.__convertor.write(text)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 162, in write
self.write_and_convert(text)
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "C:\Users\Naveen User\AppData\Roaming\Python\Python38\site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
self.wrapped.write(text[start:end])
File "C:\Users\Naveen User\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 20-23: character maps to <undefined>
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***
Btw, everything is fine with CMD or Powershell.
To Reproduce
Running py -m rich
in Git Bash For Windows shows these errors.
Platform
I am on Windows 7. The terminal I am using is Git bash. The rich version is rich==8.0.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
[BUG] Colors doesn't work on Git Bash · Issue #330 - GitHub
I got colour working with Poetry.(While colour doesn't work on cmd nor PowerShell but works in Git bash.) It uses Pastel. I think...
Read more >git - (Windows 10) GitBash not formatting colors - can't find ...
The problem is that for Windows 10.0.10586 it was enabled by default, but with Windows 10.0.14393 (Anniversary Update) it must be explicitly enabled...
Read more >ANSI color escape sequences seem broken for arc in git bash ...
Colors work fine for my git bash prompt. Colors work also fine when doing arc help|cat. - I'm not sure what is going...
Read more >8.1 Customizing Git - Git Configuration
Colors in Git · color.ui. Git automatically colors most of its output, but there's a master switch if you don't like this behavior....
Read more >Wrong color output in terminal when using GitBash - YouTrack
Project, IntelliJ IDEA ; Priority, Normal N ; Type, Bug ; State, Duplicate D ; Assignee, Sergey Simonchik.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If “is_terminal” is False it means that git bash isn’t a real terminal, and Rich is defaulting to text without color.
You can force Rich to bypass terminal detection with the following:
I don’t know much about git bash, but it looks like it is emulated and not a full terminal.
It looks like it doesn’t support unicode characters as used by the table borders. You should use
box.ASCII
when rendering tables.