agentscope-ai/agentscope · error · ImportError

Please install python-pptx to use the PowerPoint parser. You

Error message

Please install python-pptx to use the PowerPoint parser. You can install it by `pip install python-pptx` (or `pip install agentscope[rag]`).

What it means

The PowerPoint parser needs the optional python-pptx dependency. Its import inside parse() failed, raising ImportError with install instructions chained to the original error.

Source

Thrown at src/agentscope/rag/_parser/_ppt.py:202

            `list[Section]`:
                Sections in deck order.  Text sections carry
                ``{"slide": <starting at 1>}``; image sections add
                ``{"media_type": "image/..."}``.

        Raises:
            `FileNotFoundError`: If ``file`` is a ``str`` pointing to
                a path that does not exist.
            `ImportError`: If :mod:`python-pptx` is not installed.
            `ValueError`: If the bytes cannot be parsed.
        """
        if isinstance(file, str):
            with open(file, "rb") as fp:
                file = fp.read()

        try:
            from pptx import Presentation
        except ImportError as e:
            raise ImportError(
                "Please install python-pptx to use the PowerPoint "
                "parser. You can install it by "
                "`pip install python-pptx` (or "
                "`pip install agentscope[rag]`).",
            ) from e

        try:
            prs = Presentation(io.BytesIO(file))
        except Exception as e:  # pylint: disable=broad-except
            raise ValueError(
                f"Failed to parse {filename!r} as PPTX: {e}",
            ) from e

        sections: list[Section] = []
        for slide_idx, slide in enumerate(prs.slides):
            sections.extend(
                self._parse_slide(slide, slide_idx, filename),
            )

View on GitHub (pinned to e90f1c7592)

Solutions

  1. pip install python-pptx (or pip install 'agentscope[rag]')
  2. Add python-pptx to project dependencies
  3. Detect pptx availability before advertising PPT ingestion

Example fix

# before
PPTParser().parse('slides.pptx')  # ImportError

# after
# pip install 'agentscope[rag]'
PPTParser().parse('slides.pptx')
Defensive patterns

Strategy: validation

Validate before calling

try:
    import pptx  # noqa
    pptx_ok = True
except ImportError:
    pptx_ok = False

Try / catch

try:
    parser.parse(f)
except ImportError as e:
    if 'python-pptx' not in str(e):
        raise
    logger.warning('PPT parsing disabled: install python-pptx')

Prevention

When it happens

Trigger: Calling PPTParser.parse(...) without python-pptx installed (agentscope installed without [rag] extra).

Common situations: Base agentscope install; slim Docker/CI images missing optional deps.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/4428b0c9b40b88a0. Report an issue: GitHub.