r/learnpython • u/tthkbw • 2d 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?
1
u/jmacey 2d 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.4So it is working, but I'm sure there are a lot of edge cases that don't as yet.
1
u/tthkbw 2d 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 I write code for a living -- https://github.com/Diapolo10 2d 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
ftd2xxlibrary, 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.
7
u/Gshuri 2d ago
Is there a reason you need
numpy==2.5.1?That version of
numpywas released before Python 3.15 was released, hence there are nonumpywheels built for Python 3.15, which leads to the attempt to build the package from source.Can you use a later version of
numpy? Fromnumpy>=2.5.2onwards there are pre-built wheels for Python 3.15 (including macOS on both intel and apple silicon).You said your are using
uvso you can tryuv add "numpy>=2.5.2"