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

  1. Recreate the venv (UvVenvRunner.SetupUvVenv / re-run setup) so PythonPath exists.
  2. Verify File.Exists(PythonPath) (or PythonPath.Exists) before calling and re-setup if missing.
  3. Check BaseInstall.RootPath points at the correct, intact Python installation.
  4. 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

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


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)