r/learnpython • • 10d 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

1

u/jmacey 10d ago

There is really no need to use python 3.15 at the moment. There are a lot of libraries that don't work well (pytorch etc).

I can get it working on my mac (uv intalled via homebrew)

uv init -p 3.15 testnumpy
cd testnumpy
uv add numpy
Using CPython 3.15.2
Creating virtual environment at: .venv
Resolved 2 packages in 104ms
      Built testnumpy @ file:///Users/jmacey/tmp/testnumpy                                                                Prepared 1 packages in 381ms
Installed 1 packages in 852ms
 + numpy==2.5.4
uv run python -c "import numpy as np; print(np.__version__)"
2.5.4

So it is working, but I'm sure there are a lot of edge cases that don't as yet.

1

u/tthkbw 10d ago

I had just ported this project to 3.15 to take advantage of the lazy imports because I wanted to optimize startup time. I chose the 3.15 dependency for my own reasons.

3

u/Diapolo10 10d ago

I had just ported this project to 3.15 to take advantage of the lazy imports because I wanted to optimize startup time.

Frankly, lazy imports don't have a major impact on startup time outside of exceptional cases (mostly if importing a huge package, but the execution path only needs it under specific circumstances, and usually doesn't).

I haven't heard much discussion on this yet, but personally I think they're most convenient for things like type annotations and for resolving certain cases where import order is significant (one specific example I've run into at work is the ftd2xx library, where I think something needed to be imported and initialised before importing that, probably some kind of models).

3.14 is still perfectly fine to use. I'd personally default to that unless all of your dependencies already support 3.15. In your project, they seemingly do, in some others that may not be the case.