run-llama/llama_index · error · ImportError

You must install the `lxml` package to use this node parser.

Error message

You must install the `lxml` package to use this node parser.

What it means

Error "You must install the `lxml` package to use this node parser." thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/node_parser/relational/utils.py:45

    md_str = "\n".join([line[2:-2] for line in lines])

    # Check if the table is empty
    if len(md_str) == 0:
        return None

    # Use pandas to read the CSV string into a DataFrame
    try:
        return pd.read_csv(StringIO(md_str))
    except pd.errors.ParserError:
        return None


def html_to_df(html_str: str) -> Any:
    """Convert HTML to dataframe."""
    try:
        from lxml import html
    except ImportError:
        raise ImportError(
            "You must install the `lxml` package to use this node parser."
        )

    try:
        import pandas as pd
    except ImportError:
        raise ImportError(
            "You must install the `pandas` package to use this node parser."
        )

    tree = html.fromstring(html_str)
    table_element = tree.xpath("//table")[0]
    rows = table_element.xpath(".//tr")

    data = []
    for row in rows:
        cols = row.xpath(".//td")
        cols = [c.text.strip() if c.text is not None else "" for c in cols]

View on GitHub (pinned to afd0fef371)

Solutions

  1. Install lxml: `pip install lxml`.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/node_parser/relational/utils.py:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/27b28335b25be8b9. Report an issue: GitHub.