{"record":{"id":"514435db2f2a7dfb","repo":"pandas-dev/pandas","slug":"numexpr-is-not-installed-or-an-unsupported-versi","errorCode":null,"errorMessage":"'numexpr' is not installed or an unsupported version. Cannot use engine='numexpr' for query/eval if 'numexpr' is not installed","messagePattern":"'numexpr' is not installed or an unsupported version\\. Cannot use engine='numexpr' for query/eval if 'numexpr' is not installed","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"pandas/core/computation/eval.py","lineNumber":75,"sourceCode":"        Engine name.\n    \"\"\"\n    from pandas.core.computation.check import NUMEXPR_INSTALLED\n    from pandas.core.computation.expressions import USE_NUMEXPR\n\n    if engine is None:\n        engine = \"numexpr\" if USE_NUMEXPR else \"python\"\n\n    if engine not in ENGINES:\n        valid_engines = list(ENGINES.keys())\n        raise KeyError(\n            f\"Invalid engine '{engine}' passed, valid engines are {valid_engines}\"\n        )\n\n    # TODO: validate this in a more general way (thinking of future engines\n    # that won't necessarily be import-able)\n    # Could potentially be done on engine instantiation\n    if engine == \"numexpr\" and not NUMEXPR_INSTALLED:\n        raise ImportError(\n            \"'numexpr' is not installed or an unsupported version. Cannot use \"\n            \"engine='numexpr' for query/eval if 'numexpr' is not installed\"\n        )\n\n    return engine\n\n\ndef _check_parser(parser: str) -> None:\n    \"\"\"\n    Make sure a valid parser is passed.\n\n    Parameters\n    ----------\n    parser : str\n\n    Raises\n    ------\n    KeyError","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/computation/eval.py#L57-L93","documentation":"Raised by _check_engine (pandas/core/computation/eval.py:75) as an ImportError when engine='numexpr' is explicitly requested but the numexpr package is either not installed or is an unsupported version (checked via NUMEXPR_INSTALLED from pandas.core.computation.check). The numexpr backend is optional and must be installed separately; pandas refuses to fall back silently to the python engine when the user explicitly chose numexpr.","triggerScenarios":"`df.query('x > 0', engine='numexpr')` in an environment without numexpr installed, or with an incompatible numexpr version. CI/containers built from a minimal pandas install. Auto-detection only defaults to numexpr when USE_NUMEXPR is true, but an explicit request bypasses fallback.","commonSituations":"Missing dependency in requirements.txt/environment.yml, pinned incompatible numexpr version, deploying a slim Docker image, or numexpr disabled via pandas option USE_NUMEXPR.","solutions":["Install numexpr: `pip install numexpr` (or conda install numexpr) with a compatible version.","If numexpr is unavailable, switch the call to `engine='python'` or omit engine to let pandas pick.","If you control the environment, ensure numexpr is in your pinned dependencies and USE_NUMEXPR is not disabled."],"exampleFix":"# before\ndf.query('x > 0', engine='numexpr')  # numexpr missing\n\n# after (option A)\npip install numexpr\n# after (option B)\ndf.query('x > 0', engine='python')","handlingStrategy":"validation","validationCode":"def engine_or_python(engine='numexpr'):\n    try:\n        import numexpr  # noqa: F401\n    except ImportError:\n        if engine == 'numexpr':\n            return 'python'\n    return engine\n\ndf.query('x > 0', engine=engine_or_python())","typeGuard":"def numexpr_available() -> bool:\n    try:\n        import numexpr  # noqa: F401\n        from pandas.core.computation.check import NUMEXPR_INSTALLED\n        return bool(NUMEXPR_INSTALLED)\n    except ImportError:\n        return False","tryCatchPattern":"try:\n    result = df.query('x > 0', engine='numexpr')\nexcept ImportError:\n    result = df.query('x > 0', engine='python')","preventionTips":["Pin numexpr in requirements.txt/environment.yml for performance.","Fall back to engine='python' when numexpr is optional.","Probe numexpr availability at startup in slim containers."],"tags":["numexpr","eval","query","dependency","importerror","environment"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}