uv: `uv pip install gdal` fails to build, with workaround (Windows)
Summary
I’m not sure this is actually a uv problem, but I didn’t find it documented in one place anywhere so I’m doing that here. Close if there isn’t anything uv should do about this scenario; the workaround will still be here for future searchers to build on.
Problem:
D:\test> uv venv --python 3.11
D:\test> uv pip install gdal
Resolved 1 package in 230ms
x Failed to build `gdal==3.10.1`
|-> The build backend returned an error
`-> Call to `setuptools.build_meta.build_wheel` failed (exit code: 1)
[stdout]
Using numpy 2.2.2
running bdist_wheel
running build
running build_py
creating build\lib.win-amd64-cpython-311\osgeo
copying osgeo\gdal.py -> build\lib.win-amd64-cpython-311\osgeo
[...]
building 'osgeo._gnm' extension
building 'osgeo._osr' extension
[stderr]
C:\Users\mhwilkie\AppData\Local\uv\cache\builds-v0\.tmpuXEvrM\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:81: SetuptoolsWarning:
`extras_require` overwritten in `pyproject.toml` (optional-dependencies)
corresp(dist, value, root_dir)
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools":
https://visualstudio.microsoft.com/visual-cpp-build-tools/
hint: This usually indicates a problem with the package or the build environment.
Workaround solution - install a binary prebuilt wheel instead of pypi package:
- Open geospatial-wheels binary release page https://github.com/cgohlke/geospatial-wheels/releases/latest and copy url for:
- Find the binary matching your python version,
cp311is python 3.11,cp313is py 3.13, etc. - …and matching hardware,
win32,arm64,amd64 - feed the matching url to uv pip install
uv run python -m pip install https://github.com/cgohlke/geospatial-wheels/releases/download/v2025.1.20/GDAL-3.10.1-cp311-cp311-win_amd64.whl
Collecting GDAL==3.10.1
Downloading https://github.com/cgohlke/geospatial-wheels/releases/download/v2025.1.20/GDAL-3.10.1-cp311-cp311-win_amd64.whl (43.9 MB)
---------------------------------------- 43.9/43.9 MB 17.2 MB/s eta 0:00:00
Installing collected packages: GDAL
Successfully installed GDAL-3.10.1
What could/should uv do for this scenario?
- don’t attempt to build on Windows where there isn’t a tool chain (?)
- and/or offer an info message about what to do (but maybe the setuptools message with Get it with “Microsoft C++ Build Tools” serves that well enough)
- cache pip installs so that downloads aren’t repeated
Sources:
- https://www.reddit.com/r/gis/comments/1hojo4t/whats_the_point_of_pip_install_gdal_eli5/
- https://github.com/astral-sh/uv/issues/1703
Platform
MSYS_NT-10.0-19045 3.4.10-2e2ef940.x86_64 x86_64 Msy
Version
uv 0.5.30 (ddbc6e315 2025-02-10)
Python version
Python 3.11.11
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 22 (7 by maintainers)
I’ve created a proof-of-concept PEP503 index that just points to the released wheels at https://github.com/cgohlke/geospatial-wheels, and can be used together with the Linux wheels at https://gitlab.com/mentaljam/gdal-wheels.
You can find it here: https://github.com/nathanjmcdougall/geospatial-wheels-index.
You can use it with this
pyproject.tomlconfig:And then run
uv add gdal.We would like to move all our Python users to uv instead of conda-forge. The only thing missing on Windows is GDAL which is a requirement for a lot of our users. Would be great to find a solution!
Yes we’ll read
[tool.uv]sections from those scripts too.https://docs.astral.sh/uv/reference/settings/#find-links
@giswqs the Linux wheels are maintained in this project: https://gitlab.com/mentaljam/gdal-wheels I think you should open an issue there. I agree they seem to be broken for v3.11.1.
I would recommend using
uv add gdal!=3.11.1until the issue is resolved.I also note, that project is now building both Linux and Windows wheels, so potentially you could use it exclusively if you wished to do so (I haven’t tested this thoroughly)