diff --git a/crates/uv-interpreter/src/virtualenv.rs b/crates/uv-interpreter/src/virtualenv.rs index a8829d06c..461e29bfa 100644 --- a/crates/uv-interpreter/src/virtualenv.rs +++ b/crates/uv-interpreter/src/virtualenv.rs @@ -115,8 +115,19 @@ pub(crate) fn virtualenv_python_executable(venv: impl AsRef) -> PathBuf { // If none of these exist, return the standard location default_executable } else { - // Search for `python` in the `bin` directory. - venv.join("bin").join("python") + // Check for both `python3` over `python`, preferring the more specific one + let default_executable = venv.join("bin").join("python3"); + if default_executable.exists() { + return default_executable; + } + + let executable = venv.join("bin").join("python"); + if executable.exists() { + return executable; + } + + // If none of these exist, return the standard location + default_executable } } diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index eeae2cbb6..ab0485f1c 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -152,7 +152,7 @@ fn missing_venv() -> Result<()> { ----- stderr ----- warning: Requirements file requirements.in does not contain any dependencies - error: failed to canonicalize path `[VENV]/bin/python` + error: failed to canonicalize path `[VENV]/bin/python3` Caused by: No such file or directory (os error 2) "### ); diff --git a/crates/uv/tests/pip_sync.rs b/crates/uv/tests/pip_sync.rs index b0d6ac3ca..1ffbcb6cc 100644 --- a/crates/uv/tests/pip_sync.rs +++ b/crates/uv/tests/pip_sync.rs @@ -119,7 +119,7 @@ fn missing_venv() -> Result<()> { ----- stdout ----- ----- stderr ----- - error: failed to canonicalize path `[VENV]/bin/python` + error: failed to canonicalize path `[VENV]/bin/python3` Caused by: No such file or directory (os error 2) "###); }