{"record":{"id":"4e959d4c1cc9db6d","repo":"anthropics/financial-services","slug":"openpyxl-not-installed-run-pip-install-openpyxl","errorCode":null,"errorMessage":"openpyxl not installed. Run: pip install openpyxl","messagePattern":"openpyxl not installed\\. Run: pip install openpyxl","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"plugins/agent-plugins/model-builder/skills/dcf-model/scripts/validate_dcf.py","lineNumber":20,"sourceCode":"\"\"\"\nDCF Model Validation Script\nValidates Excel DCF models for formula errors and common DCF mistakes\n\"\"\"\n\nimport sys\nimport json\nfrom pathlib import Path\nfrom typing import Optional\n\n\nclass DCFModelValidator:\n    \"\"\"Validates DCF models for errors and quality issues\"\"\"\n\n    def __init__(self, excel_path: str):\n        try:\n            import openpyxl\n        except ImportError:\n            raise ImportError(\"openpyxl not installed. Run: pip install openpyxl\")\n\n        self.excel_path = excel_path\n        self.openpyxl = openpyxl\n\n        if not Path(excel_path).exists():\n            raise FileNotFoundError(f\"File not found: {excel_path}\")\n\n        self.workbook_formulas = openpyxl.load_workbook(excel_path, data_only=False)\n        self.workbook_values = openpyxl.load_workbook(excel_path, data_only=True)\n        self.errors = []\n        self.warnings = []\n        self.info = []\n        \n    def validate_all(self) -> dict:\n        \"\"\"\n        Run all validation checks\n\n        Returns:","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/anthropics/financial-services/blob/69cbc81467a5dced793eee03dec4658aa24ef856/plugins/agent-plugins/model-builder/skills/dcf-model/scripts/validate_dcf.py#L2-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"# before\npython scripts/validate_dcf.py model.xlsx\n# ImportError: openpyxl not installed. Run: pip install openpyxl\n\n# after\npython -m pip install openpyxl\npython scripts/validate_dcf.py model.xlsx","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec('openpyxl') is None:\n    raise SystemExit('openpyxl missing: python -m pip install openpyxl')","typeGuard":"def has_openpyxl() -> bool:\n    return importlib.util.find_spec('openpyxl') is not None","tryCatchPattern":"try:\n    validator = DCFModelValidator(path)\nexcept ImportError as e:\n    raise SystemExit(f'Dependency error: {e}. Install with: python -m pip install openpyxl')","preventionTips":["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"],"tags":["python","openpyxl","dependency","import-error","excel"],"backgroundTag":"missing-python-dependency","analyzedSha":"69cbc81467a5dced793eee03dec4658aa24ef856","analyzedAt":"2026-08-27T12:38:04.061Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}