-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Failed to spawn error with uv run python3.12
#11796
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
Comments
This is the intended behavior. You are probably looking for By default Since you already have Maybe we should include |
We could probably special-case this and provide a nice error message |
uv run python3.12
On a "not found" error, we can sniff for the command name ( |
Hi @zanieb , If nobody is looking into this, do you mind if I try taking a look at this issue? Just getting my feet wet with (thinking of starting with this, because this does not seem to be a mission-critical issue, so getting a solution for this doesn't seem super high-priority). Managed to reproduce with the following command: MacBookPro uv % cargo run -- run python3.9
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.76s
Running `target/debug/uv run python3.9`
error: Failed to spawn: `python3.9`
Caused by: No such file or directory (os error 2)
MacBookPro uv % Would the desired result would be something like the following? My guess is that this occurs in cases where people want to run a specific python version with uv, but is not available in their current environment. # If command starts with string `python`
error: Failed to spawn: `python3.9`
Caused by: Command `python3.9` not found. Check the list of available python versions with `uv python list`.
# For other not found commands
error: Failed to spawn: `some_command`
Caused by: Command `some_command` not found. Does this sound okay? If so, I can create a PR for this update. |
Yeah you could take a swing at it! I don't think we can just do I think we'd want to say something like..
We may need to add more context based on whether or not
and
We could also have a note about
|
@zanieb Thank you for the clarification! 🙇
Good point. Would the following suggestion be okay? // Matches strings like:
// "python3", "python3.9", "python3.10", "python4", etc.
// But NOT "python-foo", "python39", "python3abc", "python3.12b3".
// "python3.13.3" is also invalid because we cannot specify patch version when attempting to invoke python via the cli
// However, we might want to be able to specify patch version because
// `uv python pin` also works with patch versions e.g. `uv python pin 3.8.13`
fn is_python_executable_name(name: &str) -> bool {
// If this pattern is re-used or there is a common location for regex patterns, we can move this
let pattern = r"^(?i)python[0-9](\.[0-9]+)?$";
let re = Regex::new(pattern).expect("Invalid regex");
re.is_match(name)
} If we want to make this even more robust and see if we get a response from the shell, we can also incorporate the following check: // Check whether we get some return such as `Python 3.12.5`
let output = Command::new(candidate)
.arg("--version")
.output()
.map_err(|e| anyhow!("Failed to spawn command `{}`: {}", candidate.display(), e))?;
// Todo, check whether output yields something like `Python x.x.x` This + combination of the regex check is likely the most reliable method but might be overkill. For now, I will prioritize on safety first.
My guess is that the python versions mentioned above are derived from:
We need to check whether
My current implementation outputs the following: ![]() Regarding the environment, I am assuming that we will need a different message depending on the following two cases:
Generate error message using definitions above.
Generate the following message, using the python version definitions
If so, I will work on this during my spare time and submit a PR. Does this sound okay? Thank you for your patience! 🙇 |
Sorry I have limited time to reply here so I might be a bit brief. Regarding uv/crates/uv-python/src/discovery.rs Line 543 in 3a53ec3
uv/crates/uv-python/src/implementation.rs Line 36 in 2966471
I don't think you need to do this. Otherwise I think what you've written makes sense! |
@zanieb Thanks for the clarification. Is there a recommended location inside of uv to write unit tests? The reason why I am asking is because I saw the following folder: https://github.com/astral-sh/uv/tree/main/crates/uv/tests/it, Thank you once again! |
Most of the unit tests live in the same file as the code. Example: uv/crates/uv-distribution-filename/src/wheel.rs Lines 385 to 413 in 4f70d14
|
@nkitsaini Ahh I see. If I don't find unit tests within a specific file, I guess I can just add the Thank you for the clarification! 👍 |
@zanieb @nkitsaini Hi :) I just created a preliminary PR here: #12201 Just wanted to give you both a heads up. I might not be able to follow up quickly during the week, but I will do my best to follow up during the weekend. Thank you for the helpful responses in this thread! |
Summary
Platform
mac
Version
uv 0.6.3 (a0b9f22 2025-02-24)
Python version
No response
The text was updated successfully, but these errors were encountered: