uv: `uv pip install` resolution fails whereas `pip install` has no issues

Summary

Somewhat unexpectedly, uv is under-performing and failing whereas standard pip works fine

MRE

python 3.10.6 uv 0.6.3

requirements.txt:

numpy
umap-learn

pip install -r requirements.txt ✅ pip list:

Package       Version
------------- -------
joblib        1.4.2
llvmlite      0.44.0
numba         0.61.0
numpy         2.1.3
pip           25.0
pynndescent   0.5.13
scikit-learn  1.6.1
scipy         1.15.2
setuptools    75.8.0
threadpoolctl 3.5.0
tqdm          4.67.1
umap-learn    0.5.7
wheel         0.45.1

whereas trying instead with uv pip install -r requirements.txt ❌ - fails

in addition, if you were to try after the successful pip install in --dry-run, you get suggestions to downgrade packages (numba?..) uv pip install -r requirements.txt --upgrade --dry-run:

Resolved 11 packages in 39ms
Would download 4 packages
Would uninstall 4 packages
Would install 4 packages
 - llvmlite==0.44.0
 + llvmlite==0.36.0
 - numba==0.61.0
 + numba==0.53.1
 - numpy==2.1.3
 + numpy==2.2.3
 - setuptools==75.8.0
 + setuptools==75.8.2

even more odd is that you can overcome this by pinning umap-learn explicitly to the latest version in the requirements.txt file, so having the following instead works:

numpy
umap-learn==0.5.7

Platform

Ubunutu 24.04

Version

uv 0.6.3

Python version

Python 3.10.6

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

My guess is that the hint is right, but there are multiple constraints / paths to the dependency and we’re only showing one?

Yeah I presume it’s correct that it requires llvmlite but the lack of constraints leading to the finally selected version is quite misleading.

If you reverse the order of the dependencies, we’ll solve this as expected

umap-learn
numpy

As Charlie noted, this is a backtracking prioritizing issue. The resolution is “valid” but not ideal. Some details about that idea in https://docs.astral.sh/uv/concepts/resolution/#basic-examples and https://github.com/astral-sh/uv/issues/8157

I’m wondering if there needs to be better documentation here? Or error hints?

Looking at the error:

$ uv pip install numpy "pandas<2.2.0" numba
...

  × Failed to build `llvmlite==0.36.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)

   ...

  	RuntimeError: Cannot install on Python version 3.10.16; only versions >=3.6,<3.10 are supported.

There are two directions you can appraoch this problem:

  1. Because you’re getting a Python specific build error you can request “only-binary” for that package (or use :all for all pacakges):
$ uv pip install numpy "pandas<2.2.0" numba --only-binary "llvmlite"
Resolved 8 packages in 155ms
Installed 8 packages in 49ms
 + llvmlite==0.44.0
 + numba==0.61.0
 + numpy==2.1.3
 + pandas==2.1.1
 + python-dateutil==2.9.0.post0
 + pytz==2025.1
 + six==1.17.0
 + tzdata==2025.1
  1. You can add lower bounds on what packages you see failing which is first llvmlite>0.36.0 and then numba>0.53.1
uv pip install numpy "pandas<2.2.0" "numba>0.53.1" "llvmlite>0.36.0"
Resolved 8 packages in 98ms
Prepared 4 packages in 8.43s
Installed 8 packages in 52ms
 + llvmlite==0.44.0
 + numba==0.61.0
 + numpy==2.1.3
 + pandas==2.1.1
 + python-dateutil==2.9.0.post0
 + pytz==2025.1
 + six==1.17.0
 + tzdata==2025.1

There are probably better heuristics uv can do here, but there’s no way to get this right 100% of the time, pip also will need to be directed like this at times.

In general you want binary packages, especially for datascience packages, I personally have --only-binary :all: set and then --no-binary <package_name> for packages that have no wheel available.

We’re backtracking to a different llvmlite version via numba. It’s probably due to an interaction with numpy and we probably try to solve the pinned version first same as when I moved it to the top of the requirements file. The resolver heuristics are sort of complicated.

My guess is that the hint is right, but there are multiple constraints / paths to the dependency and we’re only showing one? I think we’re just backtracking here in a way that leads to a build failure. It’s not necessarily “wrong” but it’s sub-optimal.