UnicodeEncodeError: 'charmap' codec can't encode character '\u25cf' in position 2: character maps to <undefined>
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\live.py", line 122, in start
self.refresh()
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\live.py", line 241, in refresh
with self.console:
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\console.py", line 866, in __exit__
self._exit_buffer()
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\console.py", line 824, in _exit_buffer
self._check_buffer()
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\console.py", line 2033, in _check_buffer
self._write_buffer()
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\console.py", line 2069, in _write_buffer
legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_render
term.write_styled(text, style)
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\_win32_console.py", line 441, in write_styled
self.write_text(text)
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\site-packages\rich\_win32_console.py", line 402, in write_text
self.write(text)
File "C:\hostedtoolcache\windows\Python\3.12.2\x64\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u25cf' in position 2: character maps to <undefined>
Duplicate Check
Describe the bug
Unicode character encoding error when building Flet app in GitHub Actions
Description
When trying to build a Windows application using
flet build windowsin GitHub Actions, the process fails with a Unicode encoding error. The specific error occurs when Rich (used by Flet) attempts to display the character\u25cf(a black circle bullet point) in a Windows console that is using codepage CP1252.Repository with the issue
My repository where the error occurs: https://github.com/KeimaSenpai/XLauncher-ui/
Attempted Fixes
I've tried:
chcp 65001PYTHONIOENCODING=utf-8environment variable--no-rich-outputflag withflet build windowsNone of these solutions have resolved the issue.
Environment
Code sample
My GitHub Actions workflow file
Code
To reproduce
Steps to reproduce
flet build windowsExpected behavior
No response
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Windows 10
Flet version
0.27.6
Regression
No, it isn't
Suggestions
Possible Solution
The issue appears to be in how Rich handles Unicode characters when rendering to the Windows console in GitHub Actions environment. A potential fix might be:
Additional Context
This seems to specifically happen in GitHub Actions environment, as the same command works fine on local Windows machines. The character causing the issue (
\u25cf) is a black circle bullet point which Rich is trying to use for formatting its output.Logs
Logs
Error message
Full error trace
Additional details
No response