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.
Seen on:
Python
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026