{"record":{"id":"a526d6fce84fb0b3","repo":"anthropics/financial-services","slug":"openpyxl-not-installed-run-pip-install-openpyxl-a526d6","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/vertical-plugins/financial-analysis/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/vertical-plugins/financial-analysis/skills/dcf-model/scripts/validate_dcf.py#L2-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"# before\npython skills/dcf-model/scripts/validate_dcf.py model.xlsx\n# ImportError: openpyxl not installed. Run: pip install openpyxl\n\n# after\npython -m pip install openpyxl\npython skills/dcf-model/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":["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"],"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"}