LykosAI/StabilityMatrix · error · ProcessException

pip list failed with code

Error message

pip list failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}

What it means

PipList() runs `uv pip list --format=json --python <venv python>` and throws ProcessException with the exit code plus stdout/stderr when uv exits non-zero. Typically this means the venv interpreter is broken/missing or uv cannot operate on it.

Solutions

  1. Check venvRunner.Exists() and that PythonPath launches before calling PipList; recreate via Setup(existsOk: true) if broken
  2. Read stdout/stderr embedded in the exception message for uv's exact error
  3. Fix stale pyvenv.cfg (SetPyvenvCfg rewrites it, but base interpreter must exist)
  4. Delete and rebuild the venv, then reinstall packages

Example fix

// before
var packages = await venv.PipList();
// after
if (!venv.Exists())
{
    await venv.Setup(existsOk: true);
}
var packages = await venv.PipList();
Defensive patterns

Strategy: try-catch

Validate before calling

if (!venv.Exists())
{
    await venv.Setup(existsOk: true);
}

Try / catch

try
{
    var packages = await venv.PipList();
}
catch (ProcessException e)
{
    logger.LogError(e, "pip list failed: stdout={Out} stderr={Err}", e.Message);
    // consider rebuilding the venv: await venv.Setup(existsOk: true);
}

Prevention

When it happens

Trigger: uv pip list exits non-zero: venv python missing or corrupted at PythonPath, pyvenv.cfg pointing at a nonexistent base interpreter, permission errors reading site-packages, or uv failing to spawn the venv python.

Common situations: Venv directory moved/deleted after creation; base embedded Python upgraded or removed so 'home' in pyvenv.cfg is stale; corrupted site-packages; AV blocking python.exe launch.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/d4dc1b655d637684. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Python/UvVenvRunner.cs:331

        {
            throw new FileNotFoundException("uv not found", UvExecutablePath);
        }

        SetPyvenvCfg(BaseInstall.RootPath);

        var result = await ProcessRunner
            .GetProcessResultAsync(
                UvExecutablePath,
                ["pip", "list", "--format=json", "--python", PythonPath.ToString()],
                WorkingDirectory?.FullPath,
                EnvironmentVariables
            )
            .ConfigureAwait(false);

        // Check return code
        if (result.ExitCode != 0)
        {
            throw new ProcessException(
                $"pip list failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}"
            );
        }

        // There may be warning lines before the Json line, or update messages after
        // Filter to find the first line that starts with [
        var jsonLine = result
            .StandardOutput?.SplitLines(
                StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries
            )
            .Select(line => line.Trim())
            .FirstOrDefault(line =>
                line.StartsWith("[", StringComparison.OrdinalIgnoreCase)
                && line.EndsWith("]", StringComparison.OrdinalIgnoreCase)
            );

        if (jsonLine is null)
        {

View on GitHub (pinned to af93d6ef57)