AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 16, 2026, 22:01 JST

Windows cp932 crashes unattended Claude Code job with UnicodeEncodeError

Windows cp932 crashes unattended Claude Code job with UnicodeEncodeError

3 Key Points

  1. What happened

    A script that ran fine by hand failed unattended with UnicodeEncodeError, because the console's encoding was cp932 and could not output characters in the log.

  2. Why it matters

    The same job behaves differently depending on how it is launched, so hand-running it on your own terminal is not proof it will survive unattended.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The author's scripts come from Claude Code — small automations for scheduled posting, product tallies and nightly log keeping — and the crash is described as a first-hand incident, not a hypothetical. What makes it worth writing down is the gap between two ways of launching the same file: the terminal that worked and the scheduler that did not. The write-up names the specific differences that produce that gap — the execution user, the working folder, environment variables, and which Python version PATH resolves to — and recommends running the task once through its own "Run" command before waiting for night. The remaining two checks apply after a crash rather than before: report a broken streak of successes instead of the failure itself, and confirm how far a write job got before re-running it, so posts or sends are not doubled. The author says these items come from a free 25-item checklist, and that this piece is its "7. Execution environment" section.

FAQ
Why did the job fail only when run unattended?
The console's character encoding (cp932) under the scheduler could not output characters in the log, unlike a hand-run session. The execution environment is not the same when the scheduler runs it.
How does the author fix the output encoding?
Either pin the output to UTF-8 at the start of the script with sys.stdout.reconfigure(encoding="utf-8", errors="replace") and the same for stderr, or set PYTHONUTF8=1 in the task's execution environment.
What does the author recommend for failure notification?
Record the last success time and let a separate mechanism alert if it goes unupdated past a set window (for example 26 hours), rather than alerting only on a crash. A crash alert can be knocked out along with the job itself, the author says.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articlePerplexity to open-source SPACE agent sandbox