LykosAI/StabilityMatrix · error · ProcessException

pip index failed with code

Error message

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

What it means

PipIndex runs `pip index versions <package>` and throws ProcessException when the command exits non-zero. Since pip index is an experimental command and fails hard when the package (or matching distribution) cannot be found, this most often means 'no matching package/version found'.

Solutions

  1. Read the stderr in the message; if 'No matching distribution found', verify the package name and that versions exist for your Python version.
  2. Pass a custom indexUrl when the package lives on a private index.
  3. Set includePrerelease=true if only pre-releases exist for the package.
  4. Test connectivity: `venv/bin/python -m pip index versions <pkg> --index-url <url>`.

Example fix

// before
var res = venv.PipIndex("my-internal-pkg");
// after
var res = venv.PipIndex("my-internal-pkg", indexUrl: "https://pypi.mycompany.com/simple");
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify reachability of the index before querying
using var http = new HttpClient();
var resp = await http.GetAsync(indexUrl ?? "https://pypi.org/simple/");
if (!resp.IsSuccessStatusCode) throw new InvalidOperationException("package index unreachable");

Try / catch

try { return venv.PipIndex(pkg, indexUrl); }
catch (ProcessException ex) { Logger.Warn(ex, "pip index failed for {Pkg}"); return null; }

Prevention

When it happens

Trigger: Calling PipIndex(packageName, prerelease:...) when pip exits non-zero: package not on the configured index, no version matches Python version constraints, or index URL unreachable/misconfigured.

Common situations: Querying prerelease-only packages with includePrerelease=false; private index URL not set (indexUrl null) so PyPI lacks the package; corporate network blocking pypi.org; package name typo.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

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

        var noMatchingDistribution =
            result.StandardOutput?.Contains(
                "No matching distribution found",
                StringComparison.OrdinalIgnoreCase
            ) == true
            || result.StandardError?.Contains(
                "No matching distribution found",
                StringComparison.OrdinalIgnoreCase
            ) == true;

        if (noMatchingDistribution || string.IsNullOrWhiteSpace(result.StandardOutput))
        {
            return null;
        }

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

        return PipIndexResult.Parse(result.StandardOutput);
    }

    /// <summary>
    /// Run a custom install command. Waits for the process to exit.
    /// workingDirectory defaults to RootPath.
    /// </summary>
    public async Task CustomInstall(ProcessArgs args, Action<ProcessOutput>? outputDataReceived = null)
    {
        // Record output for errors
        var output = new StringBuilder();

        var outputAction =
            outputDataReceived == null

View on GitHub (pinned to af93d6ef57)