anthropics/financial-services · error · FileNotFoundError
File not found: {excel_path}
Error message
File not found: {excel_path} What it means
Raised in DCFModelValidator.__init__ of the pitch-agent copy of validate_dcf.py when Path(excel_path).exists() is False, i.e. the Excel workbook to validate does not exist on disk. It fires before openpyxl.load_workbook is called, so no workbook state is created. The actual message interpolates the exact path passed to the constructor.
Source
Thrown at plugins/agent-plugins/pitch-agent/skills/dcf-model/scripts/validate_dcf.py:26
import json
from pathlib import Path
from typing import Optional
class DCFModelValidator:
"""Validates DCF models for errors and quality issues"""
def __init__(self, excel_path: str):
try:
import openpyxl
except ImportError:
raise ImportError("openpyxl not installed. Run: pip install openpyxl")
self.excel_path = excel_path
self.openpyxl = openpyxl
if not Path(excel_path).exists():
raise FileNotFoundError(f"File not found: {excel_path}")
self.workbook_formulas = openpyxl.load_workbook(excel_path, data_only=False)
self.workbook_values = openpyxl.load_workbook(excel_path, data_only=True)
self.errors = []
self.warnings = []
self.info = []
def validate_all(self) -> dict:
"""
Run all validation checks
Returns:
Dict with validation results
"""
from datetime import datetime
self.check_sheet_structure()
self.check_formula_errors()View on GitHub (pinned to 69cbc81467)
Solutions
- Confirm the file from the script's CWD: ls -l '<path>'; if missing, locate the real output location
- Pass an absolute resolved path: DCFModelValidator(str(Path(x).resolve()))
- Sanitize externally sourced paths: p = raw.strip().strip('"\'')
- If an upstream generation step should have written the file, check its logs/temp dir for where (or whether) it wrote output
Example fix
# before
validator = DCFModelValidator('output/pitch_dcf.xlsx') # FileNotFoundError
# after
from pathlib import Path
p = Path('output/pitch_dcf.xlsx').resolve()
if not p.is_file():
raise SystemExit(f'Missing model file: {p}')
validator = DCFModelValidator(str(p)) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
p = Path(excel_path).expanduser().resolve()
if not p.is_file():
raise SystemExit(f'Model file not found: {p}')
validator = DCFModelValidator(str(p)) Type guard
def is_valid_model_path(raw: str) -> bool:
p = Path(raw).expanduser()
return p.is_file() and p.suffix.lower() in {'.xlsx', '.xlsm'} Try / catch
try:
validator = DCFModelValidator(path)
except FileNotFoundError as e:
raise SystemExit(f'Could not open model: {e}. Check the path and where the generation step wrote its output.') Prevention
- Resolve to absolute paths before constructing the validator
- Normalize paths coming from agent output or CLI args (strip quotes/whitespace)
- Pin the working directory (os.chdir or absolute paths) in generate-then-validate pipelines
When it happens
Trigger: Calling DCFModelValidator(excel_path) with a path relative to the wrong CWD, a typo, or a model file that the pitch-generation step never produced. Only the message template appears here; at runtime it contains the concrete path.
Common situations: Agent pipelines that generate the deck/model in a temp directory then validate from a different working directory; case mismatches on case-sensitive filesystems; paths copy-pasted from Windows (backslashes) on POSIX; paths extracted from LLM/CLI output containing quotes or stray whitespace.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- File not found: {excel_path}
- File not found: {excel_path}
- openpyxl not installed. Run: pip install openpyxl
- openpyxl not installed. Run: pip install openpyxl
- openpyxl not installed. Run: pip install openpyxl
AI-assisted analysis of anthropics/financial-services@69cbc81467 (2026-08-27).
Data as JSON: /api/errors/f6c625e6072ba406.
Report an issue: GitHub.