From 8e1ceba3aaa370d5aa029fac7809fd0f0d34ec02 Mon Sep 17 00:00:00 2001 From: jonathanzhan1975 <160553727+jonathanzhan1975@users.noreply.github.com> Date: Sun, 26 Apr 2026 09:16:06 +0800 Subject: [PATCH] fix: server startup on Windows + missing runtime deps Two independent issues that block `python scripts/start_web.py` after a clean install on Windows: 1. UnicodeDecodeError when streaming subprocess output `_spawn()` opened the backend / frontend stdout pipe with `text=True` but no explicit encoding. On Windows this defaults to the system ANSI codepage (e.g. `gbk` on Chinese Windows), which raises `UnicodeDecodeError` as soon as the child process emits a UTF-8 byte. Fix: pin `encoding="utf-8"` and `errors="replace"` so any locale produces clean, lossless output. 2. Missing runtime dependencies in requirements/server.txt `deeptutor/services/llm/provider_core/__init__.py` unconditionally imports `AnthropicProvider`, `OpenAICompatProvider`, and `OpenAIResponses`, which in turn import: - `loguru` (provider_core/base.py, openai_codex_provider.py, openai_responses/parsing.py) - `json_repair` (anthropic_provider.py, openai_compat_provider.py, openai_responses/parsing.py) These are declared only in `requirements/tutorbot.txt`, so `pip install -r requirements/server.txt && pip install -e .` followed by `python scripts/start_web.py` crashes with `ModuleNotFoundError` before the API server can serve a single request. Fix: declare both packages in `server.txt` with the same version bounds used by `tutorbot.txt`. Reproduced and verified on Windows 11 + Python 3.12 + a fresh venv. --- requirements/server.txt | 4 ++++ scripts/start_web.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/requirements/server.txt b/requirements/server.txt index 6c7350fb1..dc51d02e4 100644 --- a/requirements/server.txt +++ b/requirements/server.txt @@ -11,3 +11,7 @@ fastapi>=0.100.0 uvicorn[standard]>=0.24.0 websockets>=12.0 python-multipart>=0.0.6 + +# --- LLM provider runtime (unconditionally imported by provider_core) --- +loguru>=0.7.3,<1.0.0 +json-repair>=0.57.0,<1.0.0 diff --git a/scripts/start_web.py b/scripts/start_web.py index 0eb41e402..291528c58 100644 --- a/scripts/start_web.py +++ b/scripts/start_web.py @@ -78,6 +78,8 @@ def _spawn( "stderr": subprocess.STDOUT, "text": True, "bufsize": 1, + "encoding": "utf-8", + "errors": "replace", } if os.name == "nt": kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined]