rohitg00/ai-engineering-from-scratch · error · SystemExit
zstandard is required for this lesson. Install with: pip…
Error message
zstandard is required for this lesson. Install with: pip install zstandard
What it means
Import guard at module load: the optional zstandard dependency could not be imported, so the compression code in this lesson cannot run and the program exits via SystemExit with install instructions.
Solutions
- pip install zstandard in the active environment
- Verify the lesson is run with the interpreter where dependencies are installed
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at phases/19-capstone-projects/42-large-corpus-downloader/code/main.py:33 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/4d6d6880ecf684ce.
Report an issue: GitHub.
Appendix: source
Thrown at phases/19-capstone-projects/42-large-corpus-downloader/code/main.py:33
import dataclasses
import hashlib
import io
import json
import os
import struct
import sys
import tempfile
import time
import urllib.parse
import urllib.request
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import Callable, Iterable, Iterator
try:
import zstandard as zstd
except ImportError as exc:
raise SystemExit(
"zstandard is required for this lesson. Install with: pip install zstandard"
) from exc
CHUNK_BYTES = 1 << 16
DEFAULT_NUM_HASHES = 128
DEFAULT_BANDS = 32
DEFAULT_SHINGLE_WIDTH = 5
MAX_UINT64 = (1 << 64) - 1
MERSENNE_PRIME = (1 << 61) - 1
@dataclass
class ShardPlan:
"""One row of the planned shard list."""
shard_id: str
url: strView on GitHub (pinned to 39ea8a1c6d)