anthropics/financial-services · error · ImportError
openpyxl not installed. Run: pip install openpyxl
Error message
openpyxl not installed. Run: pip install openpyxl
What it means
Raised in DCFModelValidator.__init__ when the Python interpreter cannot import openpyxl, the library used to read Excel workbooks (both formulas and cached values). The validator deliberately converts the ImportError into a friendlier message with install instructions. It is an environment problem, not a model or code problem.
Source
Thrown at plugins/agent-plugins/model-builder/skills/dcf-model/scripts/validate_dcf.py:20
"""
DCF Model Validation Script
Validates Excel DCF models for formula errors and common DCF mistakes
"""
import sys
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:View on GitHub (pinned to 69cbc81467)
Solutions
- Install into the same interpreter you run the script with: python -m pip install openpyxl
- If the repo has a requirements file (e.g. skills/dcf-model/scripts/requirements.txt), install it: python -m pip install -r requirements.txt
- Verify the right environment: which python && python -c 'import openpyxl; print(openpyxl.__version__)' before re-running validate_dcf.py
- For skill/agent bundles, add openpyxl to the environment setup documented in the skill's SKILL.md so runtimes provisioning the skill install it
Example fix
# before python scripts/validate_dcf.py model.xlsx # ImportError: openpyxl not installed. Run: pip install openpyxl # after python -m pip install openpyxl python scripts/validate_dcf.py model.xlsx
Defensive patterns
Strategy: try-catch
Validate before calling
import importlib.util
if importlib.util.find_spec('openpyxl') is None:
raise SystemExit('openpyxl missing: python -m pip install openpyxl') Type guard
def has_openpyxl() -> bool:
return importlib.util.find_spec('openpyxl') is not None Try / catch
try:
validator = DCFModelValidator(path)
except ImportError as e:
raise SystemExit(f'Dependency error: {e}. Install with: python -m pip install openpyxl') Prevention
- Pin openpyxl in a requirements.txt shipped next to the skill scripts and install it in setup
- Always install with python -m pip (not bare pip) to target the running interpreter
- In containers/agent sandboxes, verify with importlib.util.find_spec('openpyxl') before invoking validation steps
When it happens
Trigger: Instantiating DCFModelValidator(excel_path) in an environment where openpyxl is not installed, e.g. running validate_dcf.py with the system Python instead of the project venv, or after a fresh clone without installing requirements. The try: import openpyxl at the top of __init__ fails and re-raises ImportError with this message.
Common situations: Running the skill script in a CI container, agent sandbox, or managed runtime that has a minimal Python install; mixing Python versions (installed into 3.11 but running 3.12); using a conda env without the package; pip install succeeding for a different interpreter (pip vs pip3 vs python -m pip).
Related errors
- openpyxl not installed. Run: pip install openpyxl
- openpyxl not installed. Run: pip install openpyxl
- File not found: {excel_path}
- File not found: {excel_path}
- File not found: {excel_path}
AI-assisted analysis of anthropics/financial-services@69cbc81467 (2026-08-27).
Data as JSON: /api/errors/4e959d4c1cc9db6d.
Report an issue: GitHub.