Known errors
Stuck for 20 minutes? Copy the exact error, then look it up here.
For an Ollama error, the server log is the first place to look. macOS: cat ~/.ollama/logs/server.log. Linux: journalctl -u ollama --no-pager --follow --pager-end. Windows: server.log in %LOCALAPPDATA%\Ollama.
Stuck on something an earlier chapter set up? Chapter 2's known errors
Which Python and pip
What you see
error: externally-managed-environmentCause
The Python on your PATH (Homebrew's, or a Linux system Python) is protected by PEP 668.Fix
Make a venv and run its Python:.venv/bin/python -m pip install httpx. Oruv add httpx. Never--break-system-packages.Status
Seen on our Mac (Homebrew 3.14.6).What you see
python3 --versionprintsPython 3.9.6on a MacCause
Apple's/usr/bin/python3answered first.Fix
Install the pinned Python (uv python install 3.13) and make the venv from it.Status
Seen on our Mac, which has Xcode. Not verified: Macs with only the Command Line Tools.- Python docs: using Python on macOS, opens in a new tabchecked 2026-10-09
What you see
torch installs as 2.8.0, numpy as 2.0.2, with no errorCause
Python 3.9 ran pip. Newer releases need 3.10 or later.Fix
Use the pinned Python. Printsys.versionin cell 1.Status
Seen on our Mac: a fullpip install torch numpyon Python 3.9.6 gave torch 2.8.0 and numpy 2.0.2, no error.- torch 2.14.1 on PyPI, opens in a new tabchecked 2026-10-09
What you see
The lockfile at uv.lock needs to be updated, but --locked was provided.(exit 1)Cause
pyproject.tomlchanged;uv.lockdid not.Fix
uv lock, thenuv sync --locked.Status
Seen on our Mac (uv 0.12.24, the pinned version, 2026-10-23).- uv docs: locking and syncing, opens in a new tabchecked 2026-10-09
What you see
uv sync --frozenfinishes, but a new package is missingCause
--frozenuses the old lock and says nothing.Fix
Use--lockedin CI.Status
Seen on our Mac (uv 0.12.24, 2026-10-23).- uv docs: locking and syncing, opens in a new tabchecked 2026-10-09
What you see
NameErrorin a notebook cell that worked yesterdayCause
A cell above it never ran in this kernel.Fix
Restart the kernel and run all cells.Status
Python's own text. The cause comes from a study of notebooks.What you see
SyntaxError: f-string: unmatched '['Cause
Python 3.11 or older ran a 3.12-style f-string.Fix
Use the pinned Python.Status
Seen on our Mac (3.9.6).- What's New in Python 3.12, opens in a new tabchecked 2026-10-09
Syntax and values
What you see
ZeroDivisionError: float division by zero(Python 3.13), orZeroDivisionError: division by zero(3.14)Cause
A duration of 0.0 in a division, for example one answer chunk.Fix
Check the window first and giveNonewhen it is 0.Status
Seen on our Mac: chapter 1'sspeed.py, line 50, against a stream with one answer chunk (Python 3.13.12; the 3.14 text in an earlier run).- Our script, 2026-10-23
What you see
TypeError: can only concatenate str (not "int") to strCause
'tokens: ' + 5Fix
An f-string:f'tokens: {n}'Status
Seen on our Mac.- Python tutorial: formatted string literals, opens in a new tabchecked 2026-10-09
What you see
KeyError: 'message'Cause
A missing key read with[].Fix
msg.get('message', {})Status
Seen on our Mac.- Python docs: json, JSON to Python conversion table, opens in a new tabchecked 2026-10-09
What you see
AttributeError: 'NoneType' object has no attribute 'get'Cause
.get('message', {})met a JSONnull, which arrives asNone.Fix
(msg.get('message') or {}).get('content')Status
Seen on our Mac.- Python docs, built-in types: dict.get, opens in a new tabchecked 2026-10-09
What you see
AttributeError: module 'statistics' has no attribute 'median'(3.13 and later add "consider renaming")Cause
A file in your folder,statistics.py, hides the real module.Fix
Rename your file.Status
Seen on our Mac (3.14.6; 3.9.6 shows only the bare error).- What's New in Python 3.13, opens in a new tabchecked 2026-10-09
What you see
AttributeError: 'dict' object has no attribute 'model'Cause
Dot access on a dict.Fix
d['model']ord.get('model')Status
Seen on our Mac.- Python tutorial: dictionaries, opens in a new tabchecked 2026-10-09
What you see
SyntaxWarning: "is" with 'int' literal. Did you mean "=="?Cause
x is 200Fix
x == 200Status
Seen on our Mac (3.14.6).What you see
TypeError: object of type 'map' has no len()Cause
map()gives a one-pass iterator.Fix
A list comprehension.Status
Seen on our Mac.- Python docs: built-in map(), opens in a new tabchecked 2026-10-09
What you see
UnboundLocalError: cannot access local variable 'x' where it is not associated with a valueCause
An assignment later in the function makes the name local.Fix
global x, or pass the value in.Status
In Python's docs.- Python FAQ: why am I getting an UnboundLocalError?, opens in a new tabchecked 2026-10-09
What you see
SyntaxError: invalid syntaxona ?? bCause
Python has no??.Fix
b if a is None else aStatus
Seen on our Mac (3.13.12).- PEP 505: None-aware operators, opens in a new tabchecked 2026-10-09
What you see
A seed or a timeout of 0 silently becomes the defaultCause
x or defaultreplaces every false value, and 0 is false.Fix
default if x is None else xStatus
Seen on our Mac (3.13.12).- Python reference: Boolean operations, opens in a new tabchecked 2026-10-09
What you see
Python prints22.2, JavaScript prints22.3, for the same numberCause
Python rounds a tie to even;toFixedrounds it up.Fix
Compare numbers within a tolerance, never the printed text.Status
Seen on our Mac (3.13.12, Node v22.23.2).- Python docs: built-in round(), opens in a new tabchecked 2026-10-09
- MDN: Number.prototype.toFixed(), opens in a new tabchecked 2026-10-09
What you see
NaNin a results file breaksJSON.parseCause
Python'sjsonwritesNaNby default.Fix
json.dumps(data, allow_nan=False), or writeNone.Status
Seen on our Mac.- Python docs: json.dump(), opens in a new tabchecked 2026-10-09
Shapes
What you see
TypeError: list indices must be integers or slices, not tupleCause
[:, -1]on a plain list.Fix
[row[-1] for row in rows], or a tensor.Status
Seen on our Mac.- Python tutorial: lists and slices, opens in a new tabchecked 2026-10-09
What you see
Shape (12, 151936) where you wanted (4, 151936)Cause
logits[-1]picked the last batch row.Fix
logits[:, -1, :]Status
In NumPy's docs.- NumPy user guide: indexing on ndarrays, opens in a new tabchecked 2026-10-09
What you see
Memory grows at every decode stepCause
You kept views of the whole logits block.Fix
.clone()the slice, orlogits_to_keep=1.Status
In Transformers' code. Seen on our Mac in NumPy: a slice needed 56Â bytes and kept 280 alive.- Transformers source: generation/utils.py (tag v5.19.0), opens in a new tabchecked 2026-10-09
- Our script, 2026-10-23
Streams and async
What you see
RuntimeWarning: coroutine '...' was never awaitedCause
You called anasync defwithoutawait.Fix
awaitit, orasyncio.create_task(...)and keep the task.Status
Seen on our Mac.- Python docs: asyncio coroutines, opens in a new tabchecked 2026-10-09
What you see
SyntaxError: 'await' outside functionCause
Top-levelawaitin a script.Fix
asyncio.run(main())Status
Seen on our Mac.- Python docs: asyncio runners, opens in a new tabchecked 2026-10-09
What you see
RuntimeError: asyncio.run() cannot be called from a running event loopCause
asyncio.run()in a notebook.Fix
Top-levelawaitin the notebook.Status
Seen on our Mac.- Python docs: asyncio runners, opens in a new tabchecked 2026-10-09
- IPython docs: asynchronous in REPL, autoawait, opens in a new tabchecked 2026-10-09
What you see
TypeError: object dict can't be used in 'await' expression(Python 3.13), orTypeError: 'dict' object can't be awaited(3.14)Cause
awaiton a plain function's result, likeawait chat(...).Fix
await asyncio.to_thread(chat, ...)Status
Seen on our Mac (3.13.12 and 3.14.6, 2026-10-23).- Python docs: asyncio.to_thread(), opens in a new tabchecked 2026-10-09
What you see
TypeError: a coroutine was expected, got {...}Cause
asyncio.create_task(chat(...)):chat()already ran and gave a dict.Fix
await asyncio.to_thread(chat, ...)Status
Seen on our Mac (3.13.12).- Python docs: asyncio.create_task(), opens in a new tabchecked 2026-10-09
What you see
TimeoutError: timed out(bare, not in aURLError)Cause
One read waited longer thantimeout.Fix
A longer timeout. CatchTimeoutErrortoo.Status
Seen on our Mac (3.14.6).- Python docs: urllib.request.urlopen(), opens in a new tabchecked 2026-10-09
What you see
httpx.ReadTimeoutCause
httpx's 5-second default on a cold call.Fix
timeout=None, or a long read timeout.Status
In httpx's docs.- httpx docs: timeouts, opens in a new tabchecked 2026-10-09
What you see
Executing <Task ...> took 1.006 seconds(debug mode)Cause
A blocking call ran inside the loop.Fix
asyncio.to_thread, or an async HTTP client.Status
Seen on our Mac.- Python docs: developing with asyncio, opens in a new tabchecked 2026-10-09
What you see
UnicodeDecodeErrorwhile reading a streamCause
A chunk was decoded alone and ended inside a character.Fix
Split bytes onb"\n"first, or use an incremental decoder.Status
Seen on our Mac.- Python docs: codecs.getincrementaldecoder(), opens in a new tabchecked 2026-10-09
What you see
json.decoder.JSONDecodeError: Unterminated string ...Cause
splitlines()cut a JSON line at U+0085.Fix
Split bytes onb"\n".Status
Seen on our Mac (a made-up line).What you see
A line{"error": "..."}mid-stream, while HTTP said 200Cause
The error came after the headers.Fix
Check every line forerror. Your port'smeasureraisesRuntimeError.Status
In Ollama's docs.- Ollama errors doc (main), opens in a new tabchecked 2026-10-09
What you see
HTTP 503server busy, please try again. maximum pending requests exceededCause
More than 512 requests in the queue.Fix
Send fewer. Retry at one layer only, a few times at most, after a growing, random wait.Status
In Ollama's code (the two spaces are in the source).- Ollama server/routes.go, handleScheduleError (tag v0.35.0), opens in a new tabchecked 2026-10-09
- Ollama server/sched.go (tag v0.35.0), opens in a new tabchecked 2026-10-09
What you see
Almost no errors, but a high p99Cause
An SDK retried for you. The OpenAI SDK retries 2Â times by default.Fix
max_retries=0, and count the errors.Status
In the OpenAI SDK's docs.- openai-python README, opens in a new tabchecked 2026-10-09
What you see
TypeError: 'async_generator' object is not iterableCause
A plainforover an async generator.Fix
async for, inside anasync def.Status
Seen on our Mac (3.12.13, 3.13.12, 3.14.6).What you see
A p95 above your slowest requestCause
statistics.quantilesuses itsexclusivemethod by default.Fix
method="inclusive". With fewer than 100 samples, report the count and the max.Status
Seen on our Mac (1369.0 against 631.0).- Python docs: statistics.quantiles(), opens in a new tabchecked 2026-10-09
Threads and processes
What you see
RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.Cause
No main guard. Spawn imports your file again in each child.Fix
Put the start code underif __name__ == "__main__":.Status
Seen on our Mac (3.13.12, 3.14.6).- Python docs: multiprocessing programming guidelines, opens in a new tabchecked 2026-10-09
What you see
The script ends, the shell says 0, but the work never ranCause
The child raised, and the parent did not checkexitcode.Fix
Checkp.exitcode, or useProcessPoolExecutor: it fails loudly.Status
Seen on our Mac (3.13.12:exitcode 1, shell status 0).- Python docs: concurrent.futures, opens in a new tabchecked 2026-10-09
What you see
_pickle.PicklingError: Can't pickle <function <lambda> at 0x...>Cause
A lambda sent to a process pool.Fix
A named function at the top of the file.Status
Seen on our Mac (3.14.6).- Python docs: multiprocessing programming guidelines, opens in a new tabchecked 2026-10-09
What you see
AttributeError: module '__main__' has no attribute '...', thenBrokenProcessPoolCause
The function was defined in a notebook or inpython -c.Fix
Put it in a.pyfile.Status
Seen on our Mac (3.14.6).- Python docs: concurrent.futures, opens in a new tabchecked 2026-10-09
What you see
Workers use an old setting, for example the old model nameCause
Spawn re-runs the top-level code. Changes made inside the guard do not reach the children.Fix
Pass settings as arguments.Status
Seen on our Mac (3.13.12).- Python docs: multiprocessing programming guidelines, opens in a new tabchecked 2026-10-09
What you see
Random prompts are not repeatable across processesCause
random.seed()in the parent does not reach the children.Fix
Seed each worker:base_seed + worker_id.Status
Seen on our Mac (3.14.6).- CPython source: random.py (tag v3.14.8), opens in a new tabchecked 2026-10-09
- Inference Perf docs: load generator, opens in a new tabchecked 2026-10-09
What you see
DeprecationWarning: This process (pid=...) is multi-threaded, use of fork() may lead to deadlocks in the child.Cause
forkwhile threads run. Shown only with-W defaultor-X dev.Fix
Use spawn.Status
Seen on our Mac (3.14.6).What you see
Worker process <pid> died unexpectedly (signal 11)(GuideLLM, macOS)Cause
fork on macOS.Fix
GUIDELLM__MP_CONTEXT_TYPE=spawnStatus
In GuideLLM's docs.- GuideLLM docs: troubleshooting, opens in a new tabchecked 2026-10-09
Build it and Break it
What you see
You usedlaunchctl setenv OLLAMA_NUM_PARALLEL 4, and nothing changedCause
The app was not restarted.Fix
Quit and reopen the Ollama app. Check theserver configline in the server log.Status
In Ollama's docs.- Ollama FAQ (tag v0.35.0), opens in a new tabchecked 2026-10-09
- Ollama server/routes.go (tag v0.35.0), opens in a new tabchecked 2026-10-02
What you see
You ranexport OLLAMA_NUM_PARALLEL=4in a terminal, and nothing changedCause
The Mac app does not read your terminal's settings.Fix
launchctl setenv OLLAMA_NUM_PARALLEL 4, then restart the app.Status
In Ollama's docs.- Ollama FAQ (tag v0.35.0), opens in a new tabchecked 2026-10-09
What you see
Later chapters behave oddly after Break itCause
OLLAMA_NUM_PARALLELis still 4.Fix
Undo it for your system (macOSlaunchctl unsetenv, Linuxsudo systemctl revert ollama.service, Windows: delete the variable), restart Ollama, and check theserver configline.Status
Seen in chapter 1.- Ollama FAQ (tag v0.35.0), opens in a new tabchecked 2026-10-09
What you see
Four slots are set, but requests still run one at a timeCause
Ollama v0.40.x serves MLX models one request at a time.Fix
Use the pinned Ollama v0.35.0.Status
In Ollama's code (v0.40.2). Not verified at run time: our Mac stays on v0.35.0.- Ollama mlxrunner/runner.go (tag v0.40.2), opens in a new tabchecked 2026-10-09
What you see
OSError: [Errno 48] Address already in usefromdrip_server.pyCause
Another program holds port 18434, often an old simulator.Fix
Stop it with Ctrl+C, or use--port 18435on the server and the matching--urlon the client.Status
Seen on our Mac (Python 3.13.12). Not verified: the Linux and Windows texts.What you see
OSError: [Errno 24] Too many open filesCause
Too many sockets in one process. On macOS a new terminal starts with a soft limit of 256 open files per process.Fix
Runulimit -n 2048in each terminal first (Break it, part 3), or split the streams over more processes.Status
Seen on our Mac (ulimit -n 256, 512 streams, 3.13.12 and 3.14.6; with 2048 the runs passed, 2026-10-09).- zsh manual: Shell Builtin Commands, ulimit, opens in a new tabchecked 2026-10-23
What you see
ModuleNotFoundError: No module named 'timing'Cause
timing.py, chapter 1's helper, is not in the same folder as the script.Fix
Downloadtiming.pyfrom the same page, into the same folder.Status
Seen on our Mac (3.13.12).What you see
ModuleNotFoundError: No module named 'drip_server'Cause
Your port's test streams from the simulator, anddrip_server.pyis not next to it.Fix
Downloaddrip_server.pyfrom the same page, into the same folder.Status
Seen on our Mac (3.13.12, 2026-10-09).What you see
fake_ollama.py is missing. Download it from the same page, into this folder.Cause
run_fake.pystarts the fake server fromfake_ollama.pyin its own folder.Fix
Downloadfake_ollama.pyinto the same folder.Status
Our script's text.What you see
Cannot reach Ollama at http://127.0.0.1:11434. Is it running? [Errno 61] Connection refusedCause
Ollama is not running. Break it, part 3, needs only the simulator.Fix
Open the Ollama app, or runollama serve.Status
Seen in chapter 1.What you see
A script in WSL 2 cannot reach the Ollama app that runs on WindowsCause
In WSL's default network mode,127.0.0.1inside WSL is not Windows.Fix
Run Ollama inside WSL 2, or turn on WSL's mirrored network mode (Windows 11 22H2 or newer).Status
In Microsoft's docs. Not verified on Windows.What you see
load_client.pywarns that client CPU is above 90%Cause
The client is the bottleneck.Fix
Add--processes.Status
Seen on our Mac (Break it, part 3, 2026-10-09;load_client.pyline 289).- Locust source: runners.py, opens in a new tabchecked 2026-10-09
What you see
warning: the simulator ran up to ... ms behind its own schedule.Cause
The simulator could not keep its own pace: too many streams for this machine, or other programs busy. Its lag mixes into yours.Fix
Close other programs, or use a smaller--n(the smaller run in Break it, part 3:--n 256, and--work-us 80in place of 40).Status
Seen on our Mac (7.4Â ms, 256 streams and 4 client processes, 2026-10-09).What you see
A test fails with a message that names a gapCause
That gap is not filled yet, or is filled the JavaScript way.Fix
Read the lesson part the message names, then fix that line.Status
Our tests' text (test_speed_port.py).