uv
uv copied to clipboard
`--system` didn't fallback to running environment when `uv` installed as python package.
- create a venv and install
uv
in it. - make sure you don't have python on the PATH.
- cd parent-dir to prevent
.venv
detection
C:\Users\User\Desktop> uvtest\.venv\Scripts\python -m uv pip list
Package Version
------- -------
uv 0.1.12
C:\Users\User\Desktop> uvtest\.venv\Scripts\python -m uv pip list --system
error: Could not find `python.exe` through `py --list-paths` or in 'PATH'. Is Python installed?
Expected: Both of them should select uvtest\.venv\Scripts\python
.
What's the use-case / motivation for invoking uv
through python -m uv
? (As an FYI, that will add a bunch of overhead to each invocation.)
(This looks straightforward to fix though.)
$ uv pip list --help
[...]
--system
List packages for the system Python.
By default, `uv` lists packages in the currently activated virtual environment, or a virtual environment (`.venv`) located in the current working directory or any parent directory, falling back to the system Python if no virtual environment is found. The `--system` option instructs `uv` to use the first Python found in the system `PATH`.
I don't understand why this is a bug. From "use the first Python found in the system PATH
" I would expect the observed behavior: Python is not in the PATH
, so uv throws an error.
Yeah, I guess this is debatable.
Why pass system to this invocation?
What's the use-case / motivation for invoking
uv
throughpython -m uv
? (As an FYI, that will add a bunch of overhead to each invocation.)
Actually, this doesn't have any usecase imo. Since first command successfully found and fallback to caller, I expected --system
should did it too.
I don't understand why this is a bug. From "use the first Python found in the system
PATH
" I would expect the observed behavior: Python is not in thePATH
, so uv throws an error.
Since --system
is shorthand of --python $(which python3)
, I think in perspective of modules run as scripts (-m
), the python/python3
executables are already on PATH environment.
An example from rye app that returns PATH variable:
> rye run hello
C:\Users\User\Desktop\New folder (2)\ttt\.venv\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\downlevel;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
What about we set UV_DEFAULT_PYTHON
in the launcher and use that as precedence over python
for the default python in uv? Many people are very used the python -m
not only working, but being necessary to do the right thing, so i'd like to support that.
I suggest a similar thing in https://github.com/astral-sh/uv/issues/2222#issuecomment-1979838755
I'm not opposed to it.