[BUG]: week1_setup notebook crashes on Windows (subprocess text=True decodes docker output as cp1252)

Author: pkuppensCreated Jul 28, 2026Updated Jul 29, 2026

Goal

Get notebooks/week1/week1_setup.ipynb to run cleanly end-to-end on Windows, and fix the doc inaccuracies found while doing so.

Problem

Running the notebook on Windows (Python 3.12.11, Docker 29.6.2, Docker Compose v5.3.1, uv 0.9.26) fails partway through Step 3 (Service Health Verification). All cells after it never execute.

1. subprocess.run(..., text=True) without encoding="utf-8" crashes on Windows

Cells 1yuulcv2wqe ("Check Current Containers") and 77j1d8uyv9j ("Service Health Check") both run:

python
result = subprocess.run(
    ["docker", "compose", "ps", "--format", "json"],
    cwd=str(project_root),
    capture_output=True,
    text=True,
    timeout=10,
)

On Windows, text=True without an explicit encoding makes Python decode the child process's stdout using locale.getpreferredencoding() — cp1252 here — instead of UTF-8. docker compose ps --format json output contains multi-byte UTF-8 characters in container labels, so the reader thread throws:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 12315: character maps to <undefined>

This exception happens in a background reader thread, so it's only printed to stderr — subprocess.run itself then returns with result.stdout = None instead of raising. The notebook's own error handling doesn't anticipate a None stdout on a successful (returncode == 0) call, so the very next line crashes for real:

AttributeError: 'NoneType' object has no attribute 'strip'

in cell 77j1d8uyv9j at if result.stdout.strip():. This is an uncaught exception (outside any relevant try), so notebook execution stops there — every subsequent cell (FastAPI/Airflow/OpenSearch/Ollama/Postgres checks) is never run in a fresh "Run All".

Fix: pass encoding="utf-8" (and ideally errors="replace") to every subprocess.run call in the notebook that parses command output, not just the two Docker Compose ones (docker --version, docker compose version, uv --version, docker exec ... ollama pull are all affected by the same root cause, they just haven't hit non-ASCII bytes yet).

2. Silent failure mode masks the real error

Even before the crash, cell 1yuulcv2wqe's bare except Exception: print("Could not check containers") swallows the actual UnicodeDecodeError, giving no actionable signal about what broke or how to fix it.

Tasks

  • Add encoding="utf-8" to all subprocess.run calls in week1_setup.ipynb that use text=True/parse stdout
  • Re-run the notebook fresh end-to-end on Windows and confirm all cells execute without error

Acceptance Criteria

  • week1_setup.ipynb runs top-to-bottom without error on Windows with uv run jupyter notebook
  • No unhandled exceptions in any cell during a clean "Restart & Run All"
  • week 2 notebook had similar change, should also run without error on Windows
  • For regression, notebooks for week 1 & 2 run on MacOS/Linux as well.

Out of Scope

  • Fix: result.stdout.strip() on None, that doesn't allow notebook to continue (this is a deal-breaker and we can't/shouldn't continue)
  • Cross-platform testing beyond Windows/macOS/Linux subprocess encoding (only fixing what's observed)
  • Rewriting the notebook's UX/structure

Environment

  • OS: Windows 11 Pro
  • Docker: 29.6.2 (build dfc4efb)
  • Docker Compose: v5.3.1
  • uv: 0.9.26
  • Python: 3.12.11

Source: jamwithai/production-agentic-rag-course