{"record":{"id":"4803bc89ca362cea","repo":"datawhalechina/hello-agents","slug":"pdfplumber-is-not-installed-install-project-depen","errorCode":null,"errorMessage":"pdfplumber is not installed. Install project dependencies before using PDF ingestion.","messagePattern":"pdfplumber is not installed\\. Install project dependencies before using PDF ingestion\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py","lineNumber":152,"sourceCode":"    df = pd.DataFrame(data_rows, columns=headers)\n    stripped = df.astype(str).apply(lambda column: column.str.strip())\n    if df.empty or (stripped == \"\").all().all():\n        return None\n    return df\n\n\ndef _extract_pdf_payload(\n    pdf_path: Path,\n    *,\n    max_pdf_pages: int,\n    max_candidate_tables: int,\n    extracted_tables_dir: Path,\n    persist_csv: bool = True,\n) -> tuple[str, list[ExtractedTableRecord]]:\n    try:\n        import pdfplumber\n    except ModuleNotFoundError as exc:  # pragma: no cover - depends on local environment\n        raise RuntimeError(\n            \"pdfplumber is not installed. Install project dependencies before using PDF ingestion.\"\n        ) from exc\n\n    extracted_tables_dir.mkdir(parents=True, exist_ok=True)\n    page_texts: list[str] = []\n    records: list[ExtractedTableRecord] = []\n    table_counter = 1\n\n    with pdfplumber.open(pdf_path) as pdf:\n        for page_index, page in enumerate(pdf.pages[: max(1, max_pdf_pages)], start=1):\n            page_text = page.extract_text() or \"\"\n            if page_text.strip():\n                page_texts.append(page_text.strip())\n\n            for raw_table in page.extract_tables() or []:\n                if len(records) >= max(1, max_candidate_tables):\n                    break\n                df = _table_to_dataframe(raw_table)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/healer-666-Academic-Data-Agent/src/data_analysis_agent/document_ingestion.py#L134-L170","documentation":"`_extract_pdf_payload` lazily imports pdfplumber and converts ModuleNotFoundError into RuntimeError('pdfplumber is not installed...') so the PDF-ingestion path fails with a clear message instead of a raw traceback. All PDF text/table extraction in the agent depends on this optional dependency.","triggerScenarios":"Running document ingestion (ingest_document or preview_pdf_tables) on a PDF in an environment where pdfplumber is not in site-packages — e.g. minimal install that skipped extras, or a venv recreated without reinstalling requirements.","commonSituations":"requirements.txt/pyproject optional-dependencies not installed (`pip install -e .` without the pdf extra), slim Docker images that trimmed packages, or dependency conflicts where pdfplumber was uninstalled by another package's installer.","solutions":["Install it: `pip install pdfplumber` in the exact interpreter/venv the agent runs under.","Verify: `python -c \"import pdfplumber; print(pdfplumber.__version__)\"`.","Add pdfplumber to the project's dependency file so all environments get it.","If installation fails, check for pinned pdfminer.six conflicts (pdfplumber requires specific versions)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef pdf_ingestion_ready() -> bool:\n    return importlib.util.find_spec(\"pdfplumber\") is not None\n\nif not pdf_ingestion_ready():\n    raise SystemExit(\"Install dependencies first: pip install pdfplumber\")","typeGuard":null,"tryCatchPattern":"try:\n    result = ingest_document(pdf_path, data_dir, logs_dir)\nexcept RuntimeError as e:\n    if \"pdfplumber is not installed\" in str(e):\n        subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"pdfplumber\"], check=True)\n        result = ingest_document(pdf_path, data_dir, logs_dir)\n    else:\n        raise","preventionTips":["Install the full dependency set (`pip install -r requirements.txt`) in every environment.","Include a startup capability check that disables PDF ingestion with a clear notice when pdfplumber is absent.","Reinstall dependencies after recreating venvs or pruning Docker images."],"tags":["dependency","modulenotfounderror","pdfplumber","pdf","python"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}