Interview Prep/Python for DevOps/Runtime, file, subprocess & encoding errors

`UnicodeEncodeError: 'ascii' codec can't encode character '✓'` when printing in a container.

IntermediateTroubleshootingRuntime, file, subprocess & encoding errors
Answer

Likely causes → The container has no UTF-8 locale (LANG unset, C/POSIX), so stdout encoding falls back to ASCII on older Pythons or tools.

Diagnose →

python -c "import sys, locale; print(sys.stdout.encoding, locale.getpreferredencoding())"
echo $LANG $LC_ALL

Fix → Set ENV LANG=C.UTF-8 (or PYTHONIOENCODING=utf-8, or PYTHONUTF8=1) in the Dockerfile.

Prevent → Base images with a UTF-8 locale; explicit encodings everywhere.

All Python for DevOps questions Roadmap: Python for automation

More on Runtime, file, subprocess & encoding errors