{"record":{"id":"925828ca0a473b07","repo":"MiniMax-AI/skills","slug":"pandas-is-not-installed-run-pip-install-pandas-o","errorCode":null,"errorMessage":"pandas is not installed. Run: pip install pandas openpyxl","messagePattern":"pandas is not installed\\. Run: pip install pandas openpyxl","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"skills/minimax-xlsx/scripts/xlsx_reader.py","lineNumber":40,"sourceCode":"import argparse\nfrom pathlib import Path\n\n\n# ---------------------------------------------------------------------------\n# Format detection and loading\n# ---------------------------------------------------------------------------\n\ndef detect_and_load(file_path: str, sheet_name_filter: str | None = None) -> dict:\n    \"\"\"\n    Load file into {sheet_name: DataFrame} dict.\n    CSV/TSV files are mapped to a single-key dict using the file stem as key.\n\n    Raises ValueError for unsupported formats or encoding failures.\n    \"\"\"\n    try:\n        import pandas as pd\n    except ImportError:\n        raise RuntimeError(\n            \"pandas is not installed. Run: pip install pandas openpyxl\"\n        )\n\n    path = Path(file_path)\n    if not path.exists():\n        raise FileNotFoundError(f\"File not found: {file_path}\")\n\n    suffix = path.suffix.lower()\n\n    if suffix in (\".xlsx\", \".xlsm\"):\n        target = sheet_name_filter if sheet_name_filter else None\n        result = pd.read_excel(file_path, sheet_name=target)\n        # pd.read_excel with sheet_name=None returns dict; with a name, returns DataFrame\n        if isinstance(result, dict):\n            return result\n        else:\n            return {sheet_name_filter: result}\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/minimax-xlsx/scripts/xlsx_reader.py#L22-L58","documentation":"detect_and_load() tries 'import pandas' at call time; if the dependency is missing it raises RuntimeError with install instructions. The import is deferred so module load never fails, but pandas is mandatory for every supported format. Note: .xlsx also needs openpyxl at read time, which the message correctly includes.","triggerScenarios":"Running xlsx_reader.py in an environment where pandas is not installed (any format), or where openpyxl is missing (for .xlsx/.xlsm).","commonSituations":"Fresh virtualenv without deps; system Python lacking pandas; CI image missing packages; pandas installed but openpyxl not, so .xlsx fails later inside pd.read_excel.","solutions":["pip install pandas openpyxl","Pin compatible versions if there is a conflict: pip install 'pandas>=2.0' openpyxl","Activate the correct virtualenv before running."],"exampleFix":"# before\npython3 xlsx_reader.py data.xlsx   # RuntimeError: pandas is not installed\n\n# after\npip install pandas openpyxl\npython3 xlsx_reader.py data.xlsx","handlingStrategy":"validation","validationCode":"import importlib.util\nfor mod in ('pandas', 'openpyxl'):\n    if importlib.util.find_spec(mod) is None:\n        raise RuntimeError(f'{mod} is not installed. Run: pip install pandas openpyxl')","typeGuard":null,"tryCatchPattern":"try:\n    sheets = detect_and_load(path)\nexcept RuntimeError as e:\n    if 'pandas' in str(e):\n        print('Install deps: pip install pandas openpyxl', file=sys.stderr)\n    raise","preventionTips":["Declare pandas+openpyxl in requirements.txt / pyproject so installs are reproducible.","Pre-flight check importlib.util.find_spec before calling detect_and_load.","Document the openpyxl requirement for .xlsx explicitly."],"tags":["dependency","python","pandas","environment"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}