uv: Python dev headers missing in venv
I think python dev headers are now missing when uv installs venv; repro (start from ubuntu 22.04):
confirmed on uv==0.5.0 and 0.5.4, not tested on other versions
export $VIRTUAL_ENV=/tmp/.venv
curl -LsSf https://astral.sh/uv/0.5.0/install.sh | sh
. $HOME/.local/bin/env
uv venv --python 3.10 $VIRTUAL_ENV
. $VIRTUAL_ENV/bin/activate
uv pip install ihm
output:
[stderr]
src/ihm_format_wrap_1.7.c:203:11: fatal error: Python.h: No such file or directory
203 | # include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
Caused by: This error likely indicates that you need to install a library that provides "Python.h" for ihm@1.7
Annoyingly, it used to work - I was able to install this package, but a couple of weeks ago binaries shipped with uv were swapped for some other builds, this affected even previous versions of uv.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (11 by maintainers)
It’s sort of a priority for me to understand the problems people are encountering and fix it here rather than recommend
sysconfigpatcher— it’s nice that it exists and I’m sure we’ll learn from it but I’d prefer a first-party solution.@arogozhnikov your failing example uses the system interpreter (3.11 is installed in the image already)
That’s why you need to install development headers via the system package manager.
If you force uv to use a managed interpreter with
--python-preference only-manage, the example worksMy last example now also works as of 0.5.10 release without the need for
CC=gcc🥳Yeah for me that’s separate from this issue (though a good point from @samypr100).
I presume the point is that we’d need #9916 for that example to work?
👋 @wjakob, the docker examples here are to provide an MRE, you can apply the same steps outside of docker.
If you’re using a system interpreter, you should install the headers, e.g., the following works:
I can’t reproduce this failure using a managed interpreter: