I’ve tripped over this on 2 machines now and end up at the same out of date StackOverflow post, so maybe this will help someone else.
Situation
When you try to print a string with a Unicode character to the console on Windows in Python, you get:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 20-21: character maps to <undefined>
Looking something like this:
Fix
Windows command-line supports unicode now, and Python 3.6+ ties into this support automatically (prior version requires win-unicode-console). You just need a slight bit of magic dust.
Add an environment variable named PYTHONIOENCODING to your environment settings, like so:
And now when you execute, you get console output instead of an error:




My roles have included accidental DBA, lone developer, systems architect, team lead, VP of Engineering, and general troublemaker. On the technical front I work in web development, distributed systems, test automation, and devop-sy areas like delivery pipelines and integration of all the auditable things.