Describe the bug
The inference scripts print check, cross and warning characters. On Windows, when stdout is redirected or piped (CI, IDE run panes, Git Bash, > file), Python encodes output with the locale code page, usually cp1252, and those characters raise UnicodeEncodeError. The error handler then raises the same exception again while trying to report it. A real console window is not affected, since Python 3.6 and later write to it as UTF-8 (PEP 528).
To Reproduce
- On Windows, run
py inference/validate_labels.py > out.txt.
- It fails on the first status line with
UnicodeEncodeError: 'charmap' codec can't encode character '✓'.
Expected behavior
The scripts run regardless of how output is captured.
Additional context
Setting PYTHONIOENCODING=utf-8 or PYTHONUTF8=1 works around it, which confirms the cause. A code fix would be ASCII status markers, or sys.stdout.reconfigure(encoding="utf-8") at startup. PR #177 replaces some of these in validate_labels.py but not the warning lines. generate_balanced_data.py:218-219 has the same issue. Logger calls in label_generator.py, train_model.py and test_model.py print "--- Logging error ---" tracebacks instead of crashing.
Found while writing the setup documentation in #138 / #178.
Describe the bug
The inference scripts print check, cross and warning characters. On Windows, when stdout is redirected or piped (CI, IDE run panes, Git Bash,
> file), Python encodes output with the locale code page, usually cp1252, and those characters raiseUnicodeEncodeError. The error handler then raises the same exception again while trying to report it. A real console window is not affected, since Python 3.6 and later write to it as UTF-8 (PEP 528).To Reproduce
py inference/validate_labels.py > out.txt.UnicodeEncodeError: 'charmap' codec can't encode character '✓'.Expected behavior
The scripts run regardless of how output is captured.
Additional context
Setting
PYTHONIOENCODING=utf-8orPYTHONUTF8=1works around it, which confirms the cause. A code fix would be ASCII status markers, orsys.stdout.reconfigure(encoding="utf-8")at startup. PR #177 replaces some of these invalidate_labels.pybut not the warning lines.generate_balanced_data.py:218-219has the same issue. Logger calls inlabel_generator.py,train_model.pyandtest_model.pyprint "--- Logging error ---" tracebacks instead of crashing.Found while writing the setup documentation in #138 / #178.