LykosAI/StabilityMatrix · error · ProcessException

pip install failed with code

Error message

pip install failed with code {Process.ExitCode}: {output.ToString().ToRepr()}

What it means

PipInstall() runs `uv pip install ... --python <venv python>` and captures all process output. If uv exits non-zero it throws ProcessException including the exit code and the accumulated output (via ToRepr). This mirrors pip's failure semantics for resolution, download, and build errors.

Solutions

  1. Read the captured output in the exception message to find the exact uv failure (resolver, network, or build)
  2. Verify the package name and version spec exist for the venv's Python version and platform
  3. Check network/proxy access to the package index; add needed --index-url/--extra-index-url args
  4. Retry on transient network errors; use Prepend of index options for packages needing custom indexes

Example fix

// before
await venv.PipInstall(new ProcessArgs("torch==9.9.9"));
// after
try
{
    await venv.PipInstall(new ProcessArgs("torch==2.1.0"));
}
catch (ProcessException e)
{
    logger.LogError(e, "uv pip install failed"); // inspect e.Message for uv output
}
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    await venv.PipInstall(args);
}
catch (ProcessException e)
{
    logger.LogError(e, "uv pip install failed: {Output}", e.Message);
    // e.Message contains exit code and full captured uv output for diagnosis
}

Prevention

When it happens

Trigger: uv pip install exits non-zero: package/version not found on any index, dependency resolution conflict, network failure reaching the index, build backend failure for sdist packages, or incompatible wheel for the platform/Python version.

Common situations: Pinning a version that doesn't exist or lacks a wheel for the OS; private index unreachable; --index-strategy unsafe-first-match pulling a bad source; transient network outage; torch/CUDA packages requiring a special index URL.

Related errors


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

Appendix: source

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

        {
            Logger.Debug($"Pip output: {s.Text}");
            // Record to output
            output.Append(s.Text);
            // Forward to callback
            outputDataReceived?.Invoke(s);
        });

        RunUvDetached(
            args.Prepend(["pip", "install"])
                .Concat(["--index-strategy", "unsafe-first-match", "--python", PythonPath.ToString()]),
            outputAction
        );
        await Process.WaitForExitAsync().ConfigureAwait(false);

        // Check return code
        if (Process.ExitCode != 0)
        {
            throw new ProcessException(
                $"pip install failed with code {Process.ExitCode}: {output.ToString().ToRepr()}"
            );
        }
    }

    /// <summary>
    /// Run a pip uninstall command. Waits for the process to exit.
    /// workingDirectory defaults to RootPath.
    /// </summary>
    public async Task PipUninstall(ProcessArgs args, Action<ProcessOutput>? outputDataReceived = null)
    {
        if (!File.Exists(UvExecutablePath))
        {
            throw new FileNotFoundException("uv not found", UvExecutablePath);
        }

        SetPyvenvCfg(BaseInstall.RootPath);

View on GitHub (pinned to af93d6ef57)