uv
uv copied to clipboard
uv fails to find python in non-venv install on Windows
When trying to run the tool on Windows, I get this rust like stack trace:
Error: The system cannot find the file specified.
(from CreateProcessA(null(), child_cmdline.into_bytes_with_nul().as_mut_ptr(),
null(), null(), 1, 0, null(), null(), addr_of!(*si),
child_process_info.as_mut_ptr()))
See https://github.com/tox-dev/tox-uv/actions/runs/7978647392/job/21784221224?pr=19
I'm using uv find_uv_bin...
Interesting, this is the same error I was getting in #1639 (cc. @MichaReiser)
Have you created and activated a virtual environment? My and Micha's conclusion from debugging #1639 was that it's not possible on Windows (yet) to use the "trick" where you pretend a virtual environment has been created and activated by doing the echo "VIRTUAL_ENV=${Python_ROOT_DIR}" >> $GITHUB_ENV
in a GitHub Actions workflow. The reason why this doesn't work on Windows is likely due to the fact that python.exe
is found in a different directory on Windows when a virtual environment hasn't been activated (it's not in a Scripts/
directory when a virtual environment hasn't been activated, and uv
assumes python.exe
will always be in a Scripts/
directory on Windows). So the VIRTUAL_ENV
trick to avoid having to create and activate an environment currently only works on Unix.
(Edit: it looks like you are indeed doing the Unix-only "trick": https://github.com/tox-dev/tox-uv/blob/a93e37e98a012d07d6ac151e097c444a77d15b0a/.github/workflows/check.yml#L43)
I outlined a cross-platform way of using uv
in a GitHub Actions workflow here: https://github.com/astral-sh/uv/issues/1386#issuecomment-1952420541
Yeah, I can do that, but sounds more like a workaround than a solution for the underlying problem 👍
Yeah, I can do that, but sounds more like a workaround than a solution for the underlying problem 👍
Oh of course. Longer-term we want to have first-class support for GitHub Actions, which I think will probably include something like #1526. We absolutely agree the current situation is far from ideal :)
I ran into this error when trying to run pytest installed with uv from a pre existing conda environment.
The main issue here is that uv
assumes that Python is located at $VIRTUAL_ENV/Scripts/python.exe
which isn't the case when pointing to a global python installation. see https://github.com/astral-sh/uv/pull/1803 for some details.
@jenshnielsen https://github.com/astral-sh/uv/pull/1803 might help with your issue, depending on the layout of the venv
directory
I wonder of this is related to the same issue I am having with embedded versions of Python: https://github.com/astral-sh/uv/issues/1656
Is a solution for this in the works? I'm preparing an internal talk on UV for users that use windows and keen to know what they should expect.
We're planning to solve this as part of https://github.com/astral-sh/uv/issues/1526
The recommended local workflow is to use a venv instead of installing dependencies globally.
Yup I'm on it.