run-llama/llama_index · error · DeprecationWarning

PandasQueryEngine has been moved to `llama-index-experimenta

Error message

PandasQueryEngine has been moved to `llama-index-experimental`.
`pip install llama-index-experimental`
`from llama_index.experimental.query_engine import PandasQueryEngine`
Note that the PandasQueryEngine allows for arbitrary code execution, 
and should be used in a secure environment.

What it means

PandasQueryEngine was removed from llama-index-core and relocated to the llama-index-experimental package because it executes arbitrary LLM-generated Python code. The core module keeps only a stub class whose __init__ unconditionally raises a DeprecationWarning with migration instructions. Any instantiation (including the legacy aliases NLPandasQueryEngine / GPTNLPandasQueryEngine) fails immediately.

Source

Thrown at llama-index-core/llama_index/core/query_engine/pandas/pandas_query_engine.py:24

This tool is not recommended to be used in a production setting, and would
require heavy sandboxing or virtual machines.

DEPRECATED: Use `PandasQueryEngine` from `llama-index-experimental` instead.

"""

from typing import Any


class PandasQueryEngine:
    """
    Pandas query engine.

    DEPRECATED: Use `PandasQueryEngine` from `llama-index-experimental` instead.
    """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        raise DeprecationWarning(
            "PandasQueryEngine has been moved to `llama-index-experimental`.\n"
            "`pip install llama-index-experimental`\n"
            "`from llama_index.experimental.query_engine import PandasQueryEngine`\n"
            "Note that the PandasQueryEngine allows for arbitrary code execution, \n"
            "and should be used in a secure environment."
        )


# legacy
NLPandasQueryEngine = PandasQueryEngine
GPTNLPandasQueryEngine = PandasQueryEngine

View on GitHub (pinned to afd0fef371)

Solutions

  1. pip install llama-index-experimental
  2. Change the import to `from llama_index.experimental.query_engine import PandasQueryEngine` and remove the core-path import
  3. Run it only in a sandboxed/secure environment (container, no secrets, restricted network) since it allows arbitrary code execution

Example fix

// before
from llama_index.core.query_engine.pandas_query_engine import PandasQueryEngine
qe = PandasQueryEngine(df=pandas_df, llm=llm)

// after
# pip install llama-index-experimental
from llama_index.experimental.query_engine import PandasQueryEngine
qe = PandasQueryEngine(df=pandas_df, llm=llm)
Defensive patterns

Strategy: validation

Validate before calling

# guard before use
try:
    from llama_index.experimental.query_engine import PandasQueryEngine  # correct path
    HAS_EXPERIMENTAL = True
except ImportError:
    HAS_EXPERIMENTAL = False

if not HAS_EXPERIMENTAL:
    raise SystemExit("pip install llama-index-experimental")

Type guard

def is_safe_query_engine(engine_cls: type) -> bool:
    """Ensure the engine is the experimental one, not the raising core stub."""
    return engine_cls.__module__.startswith("llama_index.experimental")

Prevention

When it happens

Trigger: Calling PandasQueryEngine(df, llm=...) (or NLPandasQueryEngine / GPTNLPandasQueryEngine) imported from llama_index.core.query_engine.pandas.pandas_query_engine. The stub accepts any *args/**kwargs and always raises in __init__.

Common situations: Upgrading llama-index-core to a version where the engine was extracted, or following old tutorials/docs that import from the core path; the import itself still succeeds, so the failure only appears at call time.

Related errors


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