Skip to content

uv python find doesn't find python3.12 binary in $PATH when looking for ==3.12.8 #9695

Open
@aDotInTheVoid

Description

@aDotInTheVoid

On my system I have both python3.13.0 and python3.12.8 installed through homebrew:

% which python3
/opt/homebrew/bin/python3
% which python3.12
/opt/homebrew/bin/python3.12
% python3 --version
Python 3.13.0
% python3.12 --version
Python 3.12.8

uv python list is aware of both of them:


% cat ~/.config/uv/uv.toml
python-preference = "only-system"

% uv python list
cpython-3.13.0-macos-aarch64-none    /opt/homebrew/opt/[email protected]/bin/python3.13 -> ../Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.12.8-macos-aarch64-none    /opt/homebrew/opt/[email protected]/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.9.6-macos-aarch64-none     /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3

But can only find one of them:

% uv python find '==3.13.0'
/opt/homebrew/opt/[email protected]/bin/python3.13
% uv python find '==3.12.8'
error: No interpreter found for Python ==3.12.8 in virtual environments or search path

Or with more logging:

% RUST_LOG=uv=trace uv python list
DEBUG uv 0.5.6 (Homebrew 2024-12-03)
DEBUG Searching for any Python interpreter in search path
TRACE Searching PATH for executables: python, python3, cpython, cpython3, pypy, pypy3, graalpy, graalpy3
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/bin
TRACE Found possible Python executable: /opt/homebrew/bin/python3
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
TRACE Found possible Python executable: /opt/homebrew/bin/python3.12
TRACE Cached interpreter info for Python 3.12.8, skipping probing: /opt/homebrew/bin/python3.12
DEBUG Found `cpython-3.12.8-macos-aarch64-none` at `/opt/homebrew/bin/python3.12` (search path)
TRACE Found possible Python executable: /opt/homebrew/bin/python3.13
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3.13
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3.13` (search path)
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/sbin
TRACE Checking `PATH` directory for interpreters: /usr/local/bin
TRACE Checking `PATH` directory for interpreters: /System/Cryptexes/App/usr/bin
TRACE Checking `PATH` directory for interpreters: /usr/bin
TRACE Found possible Python executable: /usr/bin/python3
TRACE Querying interpreter executable at /usr/bin/python3
DEBUG Found `cpython-3.9.6-macos-aarch64-none` at `/usr/bin/python3` (search path)
TRACE Checking `PATH` directory for interpreters: /bin
TRACE Checking `PATH` directory for interpreters: /usr/sbin
TRACE Checking `PATH` directory for interpreters: /sbin
TRACE Checking `PATH` directory for interpreters: /Library/Apple/usr/bin
TRACE Checking `PATH` directory for interpreters: /Users/aloenr01/.cargo/bin
TRACE Checking `PATH` directory for interpreters: /Applications/iTerm.app/Contents/Resources/utilities
cpython-3.13.0-macos-aarch64-none    /opt/homebrew/opt/[email protected]/bin/python3.13 -> ../Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.12.8-macos-aarch64-none    /opt/homebrew/opt/[email protected]/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.9.6-macos-aarch64-none     /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3

% RUST_LOG=uv=trace uv python find '==3.13.0'
DEBUG uv 0.5.6 (Homebrew 2024-12-03)
DEBUG Using Python request `==3.13.0` from explicit request
DEBUG Searching for Python ==3.13.0 in virtual environments or search path
TRACE Searching PATH for executables: python3, python
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/bin
TRACE Found possible Python executable: /opt/homebrew/bin/python3
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
/opt/homebrew/opt/[email protected]/bin/python3.13

% RUST_LOG=uv=trace uv python find '==3.12.8'
DEBUG uv 0.5.6 (Homebrew 2024-12-03)
DEBUG Using Python request `==3.12.8` from explicit request
DEBUG Searching for Python ==3.12.8 in virtual environments or search path
TRACE Searching PATH for executables: python3, python
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/bin
TRACE Found possible Python executable: /opt/homebrew/bin/python3
TRACE Cached interpreter info for Python 3.13.0, skipping probing: /opt/homebrew/bin/python3
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/opt/homebrew/bin/python3` (search path)
DEBUG Skipping interpreter at `/opt/homebrew/opt/[email protected]/bin/python3.13` from search path: does not satisfy request `==3.12.8`
TRACE Checking `PATH` directory for interpreters: /opt/homebrew/sbin
TRACE Checking `PATH` directory for interpreters: /usr/local/bin
TRACE Checking `PATH` directory for interpreters: /System/Cryptexes/App/usr/bin
TRACE Checking `PATH` directory for interpreters: /usr/bin
TRACE Found possible Python executable: /usr/bin/python3
TRACE Querying interpreter executable at /usr/bin/python3
DEBUG Found `cpython-3.9.6-macos-aarch64-none` at `/usr/bin/python3` (search path)
DEBUG Skipping interpreter at `/Applications/Xcode.app/Contents/Developer/usr/bin/python3` from search path: does not satisfy request `==3.12.8`
TRACE Checking `PATH` directory for interpreters: /bin
TRACE Checking `PATH` directory for interpreters: /usr/sbin
TRACE Checking `PATH` directory for interpreters: /sbin
TRACE Checking `PATH` directory for interpreters: /Library/Apple/usr/bin
TRACE Checking `PATH` directory for interpreters: /Users/aloenr01/.cargo/bin
TRACE Checking `PATH` directory for interpreters: /Applications/iTerm.app/Contents/Resources/utilities
error: No interpreter found for Python ==3.12.8 in virtual environments or search path

What I think is happening is that uv python list code does this:

.chain(find_all_minor(implementation, version, &dir_clone))
.filter(|path| !is_windows_store_shim(path))
.inspect(|path| trace!("Found possible Python executable: {}", path.display()))

where the find_all_minor means it can pick up on /opt/homebrew/bin/python3.12.

But when asking for ==3.12.8 specifically, it doesn't consider that 3.12 could be it:

VersionRequest::MajorMinor(_, _, _)
| VersionRequest::MajorMinorPatch(_, _, _, _)
| VersionRequest::MajorMinorPrerelease(_, _, _, _) => Either::Right(iter::empty()),

_Originally posted by in #9668, but that issue was unrelated. CC @zanieb _

System Information:

  • uv 0.5.6 (Homebrew 2024-12-03)
  • macOS Sonoma 14.7.1 (23H222)
  • arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguv pythonRelated to the uv python interface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions