LykosAI/StabilityMatrix · error · FileNotFoundException
Venv python not found
Error message
Venv python not found
What it means
UvVenvRunner.RunDetached throws FileNotFoundException("Venv python not found", PythonPath) when the venv's Python executable (PythonPath) does not exist just before launching a detached process. It guards against spawning a process with a missing interpreter; CustomInstall and other run helpers inherit this failure through RunDetached.
Solutions
- Recreate the venv (UvVenvRunner.SetupUvVenv / re-run setup) so PythonPath exists.
- Verify File.Exists(PythonPath) (or PythonPath.Exists) before calling and re-setup if missing.
- Check BaseInstall.RootPath points at the correct, intact Python installation.
- If the install was moved, re-point the runner's paths rather than launching against the stale location.
Example fix
// before: launching without checking the venv exists
await runner.CustomInstall(args);
// after: ensure venv first
if (!File.Exists(runner.PythonPath)) {
await runner.SetupUvVenv(); // recreate venv and interpreter
}
await runner.CustomInstall(args); Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(runner.PythonPath)) {
await runner.SetupUvVenv(); // recreate venv before running commands
} Type guard
static bool VenvExists(UvVenvRunner r) => File.Exists(r.PythonPath);
Try / catch
try { await runner.CustomInstall(args); }
catch (FileNotFoundException ex) { Logger.Error($"venv missing: {ex.FileName}"); await RecreateVenvAsync(); } Prevention
- Always ensure the venv is set up after installs, upgrades, or folder moves.
- Never assume the venv survives app updates or user cleanups.
- Centralize venv existence checks in one helper before any run call.
When it happens
Trigger: Calling CustomInstall/RunDetached (or PipInstall/PipUninstall via RunUvDetached flows that still check PythonPath) when the venv directory was deleted, the venv was created for a different platform/layout, or BaseInstall points to a nonexistent Python install.
Common situations: User deleted or moved the shared venv folder; an upgrade wiped the venv; the venv was created with `uv venv --python-version` pointing at an interpreter that failed to download; wrong working directory assumptions after relocation.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Venv creation failed with code
- pyvenv.cfg not found
- Venv python not found
- Venv creation failed with code
- pyvenv.cfg not found
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/f1b99041d243ba77.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/UvVenvRunner.cs:550
);
await process.WaitForExitAsync().ConfigureAwait(false);
return new ProcessResult { ExitCode = process.ExitCode, StandardOutput = output.ToString() };
}
[MemberNotNull(nameof(Process))]
public void RunDetached(
ProcessArgs args,
Action<ProcessOutput>? outputDataReceived,
Action<int>? onExit = null,
bool unbuffered = true
)
{
var arguments = args.ToString();
if (!PythonPath.Exists)
{
throw new FileNotFoundException("Venv python not found", PythonPath);
}
SetPyvenvCfg(BaseInstall.RootPath);
Logger.Info(
"Launching venv process [{PythonPath}] "
+ "in working directory [{WorkingDirectory}] with args {Arguments}",
PythonPath,
WorkingDirectory?.ToString(),
arguments
);
var filteredOutput =
outputDataReceived == null
? null
: new Action<ProcessOutput>(s =>
{
if (SuppressOutput.Any(s.Text.Contains))
{View on GitHub (pinned to af93d6ef57)