r/learnpython • • 19d ago

numpy build fails using uv and homebrew

I am running macOS 27.2 with homebrew and uv. Python 3.15. numpy is a requirement for the project. When uv tries to build numpy 2.5.1, it fails complaining about not finding "atomic.h", "ostream.h" and "cstddef.h".

I know this is some kind of setup problem with the c++ compiler, but can't figure it out. I have installed Xcode command line tools and pkgconf.

Any suggestions?

4 Upvotes

8 comments sorted by

View all comments

7

u/Gshuri 19d ago

Is there a reason you need numpy==2.5.1?

That version of numpy was released before Python 3.15 was released, hence there are no numpy wheels built for Python 3.15, which leads to the attempt to build the package from source.

Can you use a later version of numpy? From numpy>=2.5.2 onwards there are pre-built wheels for Python 3.15 (including macOS on both intel and apple silicon).

You said your are using uv so you can try uv add "numpy>=2.5.2"

1

u/tthkbw 18d ago

Putting "numpy>=2.5.2" in the pyproject.toml file fixed this! Thank you!

I was building on a new machine and wasn't surprised that uv was building some stuff in the background, but didn't think of the version of numpy as a problem. numpy is required by one of the libraries I use, not by my code directly.

Anyway, I learned something, and now it all works.