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__ of the vertical-plugins (financial-analysis) source copy of validate_dcf.py when openpyxl cannot be imported. openpyxl is what loads the workbook twice (data_only=False for formulas, data_only=True for cached values), so the constructor fails fast with an actionable install message instead of a raw ImportError.
Source
Thrown at plugins/vertical-plugins/financial-analysis/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 running interpreter: python -m pip install openpyxl
- Install the skill's requirements if shipped: python -m pip install -r skills/dcf-model/scripts/requirements.txt
- Sanity check: python -c 'import openpyxl; print(openpyxl.__version__)'; if it fails, fix the interpreter/venv mismatch
- Add openpyxl to the runtime provisioning for the financial-analysis skill (image, setup script, or SKILL.md install step)
Example fix
# before python skills/dcf-model/scripts/validate_dcf.py model.xlsx # ImportError: openpyxl not installed. Run: pip install openpyxl # after python -m pip install openpyxl python skills/dcf-model/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
- Ship a requirements.txt with the vertical-plugin skill and install it during environment setup
- Always pair the run command with the same interpreter used for install (python -m pip)
- Preflight-check dependencies in CI before running validation scripts
When it happens
Trigger: Instantiating DCFModelValidator(excel_path) under an interpreter lacking openpyxl — e.g. running the financial-analysis skill script with system Python, in CI, or in a container without the package. The try: import openpyxl at the top of __init__ fails and re-raises with this message.
Common situations: Minimal Docker/agent-sandbox images; pip installing into a different Python than the one executing the script; venv/conda not activated; freshly cloned repo where dependencies were never installed; Python version upgrades losing site-packages.
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/a526d6fce84fb0b3.
Report an issue: GitHub.