{"record":{"id":"38a401e0f84237a3","repo":"LykosAI/StabilityMatrix","slug":"pip-install-failed-with-code-process-exitcode-output","errorCode":null,"errorMessage":"pip install failed with code {Process.ExitCode}: {output.ToString().ToRepr()}","messagePattern":"pip install failed with code (.+?): (.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/PyVenvRunner.cs","lineNumber":249,"sourceCode":"        // Record output for errors\n        var output = new StringBuilder();\n\n        var outputAction = new Action<ProcessOutput>(s =>\n        {\n            Logger.Debug($\"Pip output: {s.Text}\");\n            // Record to output\n            output.Append(s.Text);\n            // Forward to callback\n            outputDataReceived?.Invoke(s);\n        });\n\n        RunDetached(args.Prepend(\"-m pip install\").Concat(\"--exists-action s\"), outputAction);\n        await Process.WaitForExitAsync().ConfigureAwait(false);\n\n        // Check return code\n        if (Process.ExitCode != 0)\n        {\n            throw new ProcessException(\n                $\"pip install failed with code {Process.ExitCode}: {output.ToString().ToRepr()}\"\n            );\n        }\n    }\n\n    /// <summary>\n    /// Run a pip uninstall command. Waits for the process to exit.\n    /// workingDirectory defaults to RootPath.\n    /// </summary>\n    public async Task PipUninstall(ProcessArgs args, Action<ProcessOutput>? outputDataReceived = null)\n    {\n        if (!File.Exists(PipPath))\n        {\n            throw new FileNotFoundException(\"pip not found\", PipPath);\n        }\n\n        // Record output for errors\n        var output = new StringBuilder();","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/PyVenvRunner.cs#L231-L267","documentation":"PipInstall() runs `-m pip install --exists-action s` and throws ProcessException when the pip process exits non-zero. The exception message includes the exit code and captured output (via ToRepr) to surface pip's own error (resolution conflict, network failure, missing package, etc.).","triggerScenarios":"Any pip install failure: package/version not found on the index, dependency resolution conflict, network/proxy failure, missing compiler for an sdist build, or disk full — anything making `pip install` return non-zero.","commonSituations":"Version specifier not available for the platform/Python version; private index not configured (PipIndex); corporate proxy blocking PyPI; build tools missing on Windows for packages without wheels; stale hash/requirements pinning.","solutions":["Read the captured output in the exception message to find pip's specific failure line.","Check network/proxy access to the package index; configure PipIndex if using a mirror.","Relax or correct the pinned versions in the requirements causing resolution failures.","Re-run pip install manually inside the venv to reproduce and iterate on the error."],"exampleFix":"// before\nawait venvRunner.PipInstall(\"torch==99.0\");\n// after\ntry\n{\n    await venvRunner.PipInstall(\"torch>=2.0\");\n}\ncatch (ProcessException e)\n{\n    Logger.Error(\"pip install failed: {Msg}\", e.Message);\n    throw;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await venvRunner.PipInstall(args, onOutput);\n}\ncatch (ProcessException e)\n{\n    Logger.Error(\"pip install failed: {Msg}\", e.Message); // message carries pip output\n    throw;\n}","preventionTips":["Pin requirements that exist for the target platform/Python version.","Configure PipIndex for mirrors/private indexes and verify network/proxy access.","Capture streamed output so failures are diagnosable.","Ensure build tools are present for packages without wheels."],"tags":["python","pip","process","package-install"],"backgroundTag":"command-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}