UnicodeEncodeError Python Origin: Application & API Last updated 13 Oct 2026

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.

Exact message you may see codec can't encode character'charmap' codec can't encode'ascii' codec can't encode
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

  1. Open files with encoding="utf-8"
  2. Set PYTHONIOENCODING=utf-8 or PYTHONUTF8=1
  3. Use a UTF-8 terminal / chcp 65001

Detailed fix by platform

Windows

  1. set PYTHONUTF8=1 (or set it in system environment variables)

How to diagnose

  1. Destination — Console or file?
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

22021 — ERROR: invalid byte sequence for encoding "UTF8": 0x00 (PostgreSQL)22021AttributeError — AttributeError: 'X' object has no attribute 'y' (Python)AttributeErrorBOM output — Unexpected characters at the top of the page / headers already sent by BOM (PHP)BOM outputConnectionRefusedError — ConnectionRefusedError: [Errno 111] Connection refused (Python)ConnectionRefusedErrorEvent loop is closed — RuntimeError: Event loop is closed (Python)Event loop is closedUnicodeDecodeError — UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 10: invalid start byte (Python)UnicodeDecodeErrorURIError — URIError: URI malformed (JavaScript)URIErrorUnicodeEn…

Explore the map of this error Full error map →

🧠 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.