{"record":{"id":"71a228704d5d2fd4","repo":"pandas-dev/pandas","slug":"unable-to-import-required-dependency-dependency","errorCode":null,"errorMessage":"Unable to import required dependency {_dependency}. Please see the traceback for details.","messagePattern":"Unable to import required dependency (.+?)\\. Please see the traceback for details\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"pandas/__init__.py","lineNumber":13,"sourceCode":"from __future__ import annotations\n\n__docformat__ = \"restructuredtext\"\n\n# Let users know if they're missing any of our hard dependencies\n# except tzdata (see https://github.com/pandas-dev/pandas/issues/63264)\n_hard_dependencies = (\"numpy\", \"dateutil\")\n\nfor _dependency in _hard_dependencies:\n    try:\n        __import__(_dependency)\n    except ImportError as _e:  # pragma: no cover\n        raise ImportError(\n            f\"Unable to import required dependency {_dependency}. \"\n            \"Please see the traceback for details.\"\n        ) from _e\n\ndel _hard_dependencies, _dependency\n\ntry:\n    # numpy compat\n    from pandas.compat import (\n        is_numpy_dev as _is_numpy_dev,  # pyright: ignore[reportUnusedImport] # noqa: F401\n    )\nexcept ImportError as _err:  # pragma: no cover\n    _module = _err.name\n    raise ImportError(\n        f\"C extension: {_module} not built. If you want to import \"\n        \"pandas from the source directory, you may need to run \"\n        \"'python -m pip install -ve . --no-build-isolation -Ceditable-verbose=true' \"\n        \"to build the C extensions first.\"","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/__init__.py#L1-L31","documentation":"Raised at pandas import time when one of its hard dependencies (numpy or dateutil, defined in _hard_dependencies) cannot be imported. pandas re-raises the underlying ImportError chained via 'from _e' so the original traceback is preserved. tzdata is intentionally excluded. This is a fatal startup error: nothing in pandas is usable until it is resolved.","triggerScenarios":"import pandas executes the loop at pandas/__init__.py:9-16; if __import__('numpy') or __import__('dateutil') raises ImportError, this message is raised.","commonSituations":"Fresh venv without numpy/dateutil installed, a broken numpy wheel (e.g. mismatched Python ABI), a corrupted environment after a partial pip upgrade, or sys.path shadowing where a local 'numpy.py' shadows the real package.","solutions":["Run `python -m pip install numpy python-dateutil` (or reinstall pandas with `pip install --force-reinstall pandas`).","Verify the install with `python -c \"import numpy; print(numpy.__version__)\"` and `python -c \"import dateutil\"`.","If numpy fails to import, check for ABI mismatch (`numpy.dtype` segfaults or ImportError about C extension) and reinstall numpy matching your Python version.","Check there is no local file named numpy.py or a directory named numpy on sys.path shadowing the real package."],"exampleFix":"# before\npython -c \"import pandas\"  # ImportError: Unable to import required dependency numpy\n\n# after\npython -m pip install numpy python-dateutil\npython -c \"import pandas; print(pandas.__version__)\"","handlingStrategy":"validation","validationCode":"import importlib.util\nfor dep in (\"numpy\", \"dateutil\"):\n    if importlib.util.find_spec(dep) is None:\n        raise SystemExit(f\"Missing hard dependency: {dep}. Run: pip install {dep}\")\nimport pandas  # now safe","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin pandas and its hard deps in requirements.txt / pyproject.toml.","Use a fresh virtualenv per project to avoid cross-contamination.","Run `python -c 'import numpy, dateutil'` as a smoke test in CI before importing pandas."],"tags":["import","dependencies","numpy","environment"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}