Skip to content

[Python] Numpy constraint is present in the build but not in the runtime constraints #53954

Open

Description

@oliversheridanmethven

Describe the bug, including details regarding any error messages, version, and platform.

Here https://github.com/apache/arrow/blob/apache-arrow-26.0.0/python/pyproject.toml#L25 we have:

[build-system]
requires = [
    "numpy>=2.0",
]

For the project dependencies, there do not appear to be any mentioned that I can see. However, when I run the code, I see:

  File ...
    import pyarrow as pa
  File ...
    from pyarrow.lib import ...
  File "pyarrow/lib.pyx", line 42, in init pyarrow.lib
ImportError: pyarrow requires NumPy 2.0 or newer, found 1.26.4

when I use pyarrow==26.0.0.

It seems to me that there is a missing dependency that should be present to constraint the numpy version in the runtime dependencies (alongside the build time ones).

Component(s)

Python

Activity

  1. changed the title [-]Numpy constraint is present in the build but not in the runtime constraints[/-] [+][Python] Numpy constraint is present in the build but not in the runtime constraints[/+] on Oct 16, 2026
  2. mohamd764 commented on Oct 16, 2026

    @mohamd764

    I can confirm the behaviour and the version boundary (Python 3.12.15, Linux x86_64, uv pip install):

    pyarrow numpy 1.26.4
    21.0.0, 22.0.0, 23.0.1, 24.0.0, 25.0.1 import pyarrow works, pa.array(np.arange(3)).to_numpy() works
    26.0.0 ImportError: pyarrow requires NumPy 2.0 or newer, found 1.26.4

    The 26.0.0 wheel's METADATA has no Requires-Dist lines at all, so pip/uv have nothing to resolve against.

    Some context in case it helps: this was an intentional change for 26.0.0 in #50769 (GH-48473, "Require numpy 2.0"). The check is in pyarrow/lib.pyx (lines 40-45 at apache-arrow-26.0.0) and only runs if import numpy succeeds. NumPy is still an optional runtime dependency. With numpy uninstalled, pyarrow 26.0.0 imports fine, and a Parquet write/read round trip and pc.sum work. That's probably why there's no runtime requirement. Adding numpy>=2 to [project].dependencies (what #53971 proposed; it was closed without being merged) would make numpy mandatory for everyone, and package metadata has no way to say "numpy>=2, but only if numpy is installed".

    The install docs for 26.0.0 already list "NumPy 2.0 or higher" under optional dependencies, which matches this behaviour.

    Practical options for now: pip install "numpy>=2" alongside pyarrow 26, or pin pyarrow<26 if you need to stay on NumPy 1.x. On the user side, a constraints file with numpy>=2 also does the job. I tried this in a fresh Python 3.12 venv with -c constraints.txt:

    • pyarrow==26.0.0 alone: numpy is not installed
    • pyarrow==26.0.0 "numpy<2": resolution fails (pip and uv both)
    • pyarrow==26.0.0 pandas==2.2.3: numpy 2.5.4 is picked (uv)

    A constraint doesn't upgrade a numpy 1.x that's already installed if you only install pyarrow, though (checked with uv). In that case you still have to upgrade numpy yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions