{"record":{"id":"f65f38a930cbeb71","repo":"pandas-dev/pandas","slug":"pandas-requires-version-minimum-version-or-new","errorCode":null,"errorMessage":"Pandas requires version '{minimum_version}' or newer of '{parent}' (version '{version}' currently installed).","messagePattern":"Pandas requires version '(.+?)' or newer of '(.+?)' \\(version '(.+?)' currently installed\\)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"pandas/compat/_optional.py","lineNumber":188,"sourceCode":"    else:\n        module_to_get = module\n    minimum_version = min_version if min_version is not None else VERSIONS.get(parent)\n    if minimum_version:\n        version = get_version(module_to_get)\n        if version and Version(version) < Version(minimum_version):\n            msg = (\n                f\"Pandas requires version '{minimum_version}' or newer of '{parent}' \"\n                f\"(version '{version}' currently installed).\"\n            )\n            if errors == \"warn\":\n                warnings.warn(\n                    msg,\n                    UserWarning,\n                    stacklevel=find_stack_level(),\n                )\n                return None\n            elif errors == \"raise\":\n                raise ImportError(msg)\n            else:\n                return None\n\n    return module\n","sourceCodeStart":170,"sourceCodeEnd":193,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/compat/_optional.py#L170-L193","documentation":"Raised by import_optional_dependency (compat/_optional.py:172-188) when an optional dependency IS installed but its version is older than the minimum pandas requires (min_version arg, or the VERSIONS dict default). With errors='raise' (default) it raises ImportError; errors='warn' emits a UserWarning and returns None; errors='ignore' silently returns None. Version comparison uses packaging.Version (via pandas.util.version.Version).","triggerScenarios":"pandas requires e.g. a minimum numpy/pyarrow/openpyxl/sqlalchemy version (declared in VERSIONS). import_optional_dependency compares Version(installed) < Version(minimum_version) and raises. Hitting it means the package imports but is too old for this pandas release.","commonSituations":"Upgrading pandas in an environment with stale optional deps (e.g. pandas 2.x needs newer numpy than 1.x); system Python with OS-packaged older libraries; pinning a dependency for compatibility with another tool that needs the old version.","solutions":["Upgrade the dependency to at least the stated minimum: pip install --upgrade '<pkg>>=<min>'.","Check the installed version: python -c 'import <pkg>; print(<pkg>.__version__)'.","If upgrading is blocked, downgrade pandas to a release that accepts your older dependency version.","If you call import_optional_dependency directly, pass errors='warn' or 'ignore' to tolerate the old version (at your own risk)."],"exampleFix":"# before — openpyxl 2.x, pandas needs >= 3.0\npd.read_excel('f.xlsx')\n\n# after\n# shell: pip install --upgrade 'openpyxl>=3.0'\npd.read_excel('f.xlsx')","handlingStrategy":"validation","validationCode":"from packaging.version import Version\nimport importlib\nmod = importlib.import_module(name)\ninstalled = getattr(mod, '__version__', None)\nif installed is None or Version(installed) < Version(minimum):\n    raise ImportError(f'{name}>={minimum} required, got {installed}')","typeGuard":null,"tryCatchPattern":"try:\n    import_optional_dependency(name, min_version=minimum)\nexcept ImportError:\n    # too old — upgrade or fall back to older pandas\n    ...","preventionTips":["Pin compatible lower bounds for optional deps in your requirements.","Upgrade deps whenever you upgrade pandas.","In CI, install the full pandas extras to surface version floors early."],"tags":["compat","dependencies","version","optional-dependency","importerror"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}