UnicodeEncodeError: 'charmap' codec can't encode character '\u2192'
Python tried to write text in an encoding that can’t represent some characters — common in Windows consoles and files opened without encoding.
codec can't encode character'charmap' codec can't encode'ascii' codec can't encode Meaning
Windows console/legacy code pages (cp1252, charmap) can’t print many Unicode characters. Writing files without encoding= uses the platform default.
Common causes
- Printing Unicode to a Windows console
- open(..., "w") without encoding="utf-8"
- Old ASCII-only locale on Linux servers (LANG=C)
⚡ Quick fix
- Open files with encoding="utf-8"
- Set PYTHONIOENCODING=utf-8 or PYTHONUTF8=1
- Use a UTF-8 terminal / chcp 65001
Detailed fix by platform
Windows
set PYTHONUTF8=1(or set it in system environment variables)
How to diagnose
- Destination — Console or file?
- Encoding — Which codec is named?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Python
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026