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() throws ProcessException when `pip list --format=json` exits non-zero, embedding exit code, stdout, and stderr in the message. Pip's JSON output is then filtered to the first line starting with '[' to strip warnings/update banners.

Solutions

  1. Inspect stdout/stderr in the exception message for pip's traceback.
  2. Reinstall/repair pip in the venv (`python -m ensurepip --upgrade` or reinstall pip wheel).
  3. Remove corrupted dist-info directories in venv site-packages if a specific package's metadata is at fault.
  4. Recreate the venv if the environment is systematically broken.

Example fix

// before
var packages = await venvRunner.PipList();
// after
IReadOnlyList<PipPackageInfo> packages;
try
{
    packages = await venvRunner.PipList();
}
catch (ProcessException e)
{
    Logger.Warning("pip list failed, assuming empty: {Msg}", e.Message);
    packages = Array.Empty<PipPackageInfo>();
}
Defensive patterns

Strategy: fallback

Try / catch

List<PipPackageInfo> packages;
try
{
    packages = (List<PipPackageInfo>)await venvRunner.PipList();
}
catch (ProcessException e)
{
    Logger.Warning("pip list unavailable: {Msg}", e.Message);
    packages = new List<PipPackageInfo>(); // empty fallback
}

Prevention

When it happens

Trigger: pip list failing due to corrupted site-packages metadata (unreadable dist-info), broken pip installation inside the venv, or environment issues causing pip itself to crash on startup.

Common situations: Corrupted package metadata from interrupted installs; pip upgraded/broken mid-flight; mismatched base-interpreter after embedded Python update so pip's vendored imports fail.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Python/PyVenvRunner.cs:314

        {
            throw new FileNotFoundException("pip not found", PipPath);
        }

        SetPyvenvCfg(BaseInstall.RootPath);

        var result = await ProcessRunner
            .GetProcessResultAsync(
                PythonPath,
                "-m pip list --format=json",
                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)