shareAI-lab/learn-claude-code · error · GoalError
Install dependencies first: pip install -r requirements.txt
Error message
Install dependencies first: pip install -r requirements.txt
What it means
make_live_session failed to import the optional third-party packages 'anthropic' and/or 'dotenv' (s17_goal_loop/code.py:815). The live path is optional, so these dependencies are not installed with the base code; ImportError is caught and re-raised as GoalError telling you to install requirements.txt.
Source
Thrown at s17_goal_loop/code.py:815
return f"Edited {path.relative_to(self.workdir)}"
if name == "glob":
matches = [
match
for match in glob.glob(str(arguments["pattern"]), root_dir=self.workdir)
if (self.workdir / match).resolve().is_relative_to(self.workdir)
]
return "\n".join(matches[:200]) if matches else "(no matches)"
raise GoalError(f"unknown tool '{name}'")
def make_live_session(workdir: Path) -> AgentSession:
try:
from anthropic import Anthropic
from dotenv import load_dotenv
except ImportError as error:
raise GoalError(
"Install dependencies first: pip install -r requirements.txt"
) from error
load_dotenv(override=True)
model = os.getenv("MODEL_ID")
if not model:
raise GoalError("MODEL_ID is required in the environment or .env")
evaluator_model = (
os.getenv("GOAL_EVALUATOR_MODEL_ID")
or os.getenv("ANTHROPIC_DEFAULT_HAIKU_MODEL")
or model
)
if os.getenv("ANTHROPIC_BASE_URL"):
os.environ.pop("ANTHROPIC_AUTH_TOKEN", None)
client = Anthropic(base_url=os.getenv("ANTHROPIC_BASE_URL"))
evaluator = PromptGoalEvaluator(client=client, model=evaluator_model)
block_cap = int(
os.getenv(View on GitHub (pinned to 985456f4ad)
Solutions
- Run pip install -r requirements.txt inside the venv/interpreter you will execute with
- Verify with 'python -c "import anthropic, dotenv"' using the same interpreter
- If using uv/poetry, run through 'uv run python ...' / 'poetry run python ...' so the project env is used
Example fix
# before $ python -m s17_goal_loop.code error: Install dependencies first: pip install -r requirements.txt # after $ python -m venv .venv && source .venv/bin/activate $ pip install -r requirements.txt $ python -m s17_goal_loop.code
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
missing = [m for m in ("anthropic", "dotenv") if importlib.util.find_spec(m) is None]
if missing:
raise SystemExit(f"install deps first: {', '.join(missing)} (pip install -r requirements.txt)")
session = make_live_session(workdir) Prevention
- Install requirements.txt into the exact interpreter you run with (venv/uv/poetry)
- Smoke-test with 'python -c "import anthropic, dotenv"' before the first session
- Run via 'uv run'/'poetry run' so the project environment is always used
When it happens
Trigger: Calling make_live_session(path) in an environment where 'pip install -r requirements.txt' (which provides anthropic and python-dotenv) has not been run, or where a different virtualenv/interpreter is active than the one the packages were installed into.
Common situations: Fresh clone, no venv set up; running under a different python (system vs venv vs poetry/uv env); IDE launching with a stale interpreter; installing with --user into a Python other than the one runs the script.
Related errors
- MODEL_ID is required in the environment or .env
- Not in a git repository. worktree tools require git.
- Memory directory escapes the workspace
- Dependency not found: {dependency}
- Dependency not found: {dependency}
AI-assisted analysis of shareAI-lab/learn-claude-code@985456f4ad (2026-08-14).
Data as JSON: /api/errors/667a774809310891.
Report an issue: GitHub.