-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected python discovery rules #7562
Comments
This is surprising to me as well :) will investigate |
For reference I will link to this one: #7604 |
@zanieb this problem is 100% reproducible for maintainers and others isn't it? |
Yes. Actually looking closer at this though and I'm a bit confused at what surprised me initially. We prefer managed interpreters by default so once you install one it should be used over system interpreters. I think this is working as-intended. |
So this bug should be closed then because it is working as designed? But surely you can see the problem here? A user installs a very old version just for compatibility testing for a specific venv etc, then from then on it becomes his default python for all new venvs! |
Then I'd recommend changing your |
(I still think we can improve the documentation here, at least) |
I'd like a |
I've run into a similar The My initial worry was that this may stem from undefined directory iteration order, since uv just takes the first acceptable result, and doesn't seem to sort directory entries anywhere. However, that can't be it, as uv consistently flip-flops between two choices, whereas directory entry order should remain stable unless entries are added/deleted. Then I had hoped that recent changes to the relevant searching code would have resolved this: But alas, the observed behaviour is unchanged. I suspect that uv is poisoning its caches with unusable results earlier in the Details on my setupI load the project's venv into my $ echo $PATH
$PROJECT/.venv/bin:$HOME/.pyenv/shims:... When starting the experiment, the venv's $ ls -l .venv/bin | grep python
lrwxrwxrwx ... python -> $HOME/.pyenv/versions/3.9.19/bin/python3.9
lrwxrwxrwx ... python3 -> python
lrwxrwxrwx ... python3.9 -> python My pyenv installation contains 3.8, 3.9, 3.11, and 3.12.2, but per $ ls ~/.pyenv/shims/python* | grep -v -
$HOME/.pyenv/shims/python
$HOME/.pyenv/shims/python3
$HOME/.pyenv/shims/python3.11
$HOME/.pyenv/shims/python3.12
$HOME/.pyenv/shims/python3.8
$HOME/.pyenv/shims/python3.9 I tested with two $ uv@2024-09-28 --version
uv 0.4.17 (9312a0800 2024-09-28)
$ uv --version
uv 0.4.17 When running logs for 3.9 → 3.12 flip$ uv@2024-09-28 --verbose venv
DEBUG uv 0.4.17
DEBUG Found project root: `$PROJECT`
DEBUG No workspace root found, using project root
DEBUG Searching for Python >=3.8 in managed installations or system path
DEBUG Searching for managed installations at `$HOME/.local/share/uv/python`
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python`: system interpreter required
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python3` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3`: system interpreter required
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python3.9` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3.9`: system interpreter required
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python`: system interpreter required
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python3` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python3.12` (search path)
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
DEBUG Removing existing directory
Activate with: source .venv/bin/activate If we run logs for 3.12 → 3.9 flop$ uv@2024-09-28 --verbose venv
DEBUG uv 0.4.17
DEBUG Found project root: `$PROJECT`
DEBUG No workspace root found, using project root
DEBUG Searching for Python >=3.8 in managed installations or system path
DEBUG Searching for managed installations at `$HOME/.local/share/uv/python`
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python3` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$PROJECT/.venv/bin/python3.12` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3.12`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python3` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3`: system interpreter required
DEBUG Found `cpython-3.12.3-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python3.12` (search path)
DEBUG Ignoring Python interpreter at `$PROJECT/.venv/bin/python3.12`: system interpreter required
DEBUG Found `cpython-3.9.19-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python3.9` (search path)
Using CPython 3.9.19 interpreter at: $HOME/.pyenv/versions/3.9.19/bin/python3.9
Creating virtual environment at: .venv
DEBUG Removing existing directory
Activate with: source .venv/bin/activate Of course things work perfectly if I force a particular Python version. It seems that If I exit the venv, then logs when re-creating the venv from the outside$ uv@2024-09-28 --verbose venv
DEBUG uv 0.4.17
DEBUG Found project root: `$PROJECT`
DEBUG No workspace root found, using project root
DEBUG Searching for Python >=3.8 in managed installations or system path
DEBUG Searching for managed installations at `$HOME/.local/share/uv/python`
DEBUG Found `cpython-3.12.2-linux-x86_64-gnu` at `$HOME/.pyenv/shims/python` (search path)
Using CPython 3.12.2 interpreter at: $HOME/.pyenv/versions/3.12.2/bin/python
Creating virtual environment at: .venv
DEBUG Removing existing directory
Activate with: source .venv/bin/activate |
You described it really well. This is mostly what I had experience in #7604. One detail that played role in my case I had another PS. Also working here on the |
Thanks for all the details. I'll need to dig into this more during the week, but pyenv is generally quite problematic for our caching since their shim can return any interpreter. |
I wondered why my venv was using a very old Python version and then did the following test:
That is surprising to users, particularly when
uv
is choosing such an old version 3.8 for default use compared to 3.12.The text was updated successfully, but these errors were encountered: