{"record":{"id":"d4dc1b655d637684","repo":"LykosAI/StabilityMatrix","slug":"pip-list-failed-with-code-result-exitcode-result-d4dc1b","errorCode":null,"errorMessage":"pip list failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}","messagePattern":"pip list failed with code (.+?): (.+?), (.+?)","errorType":"exception","errorClass":"ProcessException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvVenvRunner.cs","lineNumber":331,"sourceCode":"        {\n            throw new FileNotFoundException(\"uv not found\", UvExecutablePath);\n        }\n\n        SetPyvenvCfg(BaseInstall.RootPath);\n\n        var result = await ProcessRunner\n            .GetProcessResultAsync(\n                UvExecutablePath,\n                [\"pip\", \"list\", \"--format=json\", \"--python\", PythonPath.ToString()],\n                WorkingDirectory?.FullPath,\n                EnvironmentVariables\n            )\n            .ConfigureAwait(false);\n\n        // Check return code\n        if (result.ExitCode != 0)\n        {\n            throw new ProcessException(\n                $\"pip list failed with code {result.ExitCode}: {result.StandardOutput}, {result.StandardError}\"\n            );\n        }\n\n        // There may be warning lines before the Json line, or update messages after\n        // Filter to find the first line that starts with [\n        var jsonLine = result\n            .StandardOutput?.SplitLines(\n                StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries\n            )\n            .Select(line => line.Trim())\n            .FirstOrDefault(line =>\n                line.StartsWith(\"[\", StringComparison.OrdinalIgnoreCase)\n                && line.EndsWith(\"]\", StringComparison.OrdinalIgnoreCase)\n            );\n\n        if (jsonLine is null)\n        {","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvVenvRunner.cs#L313-L349","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check venvRunner.Exists() and that PythonPath launches before calling PipList; recreate via Setup(existsOk: true) if broken","Read stdout/stderr embedded in the exception message for uv's exact error","Fix stale pyvenv.cfg (SetPyvenvCfg rewrites it, but base interpreter must exist)","Delete and rebuild the venv, then reinstall packages"],"exampleFix":"// before\nvar packages = await venv.PipList();\n// after\nif (!venv.Exists())\n{\n    await venv.Setup(existsOk: true);\n}\nvar packages = await venv.PipList();","handlingStrategy":"try-catch","validationCode":"if (!venv.Exists())\n{\n    await venv.Setup(existsOk: true);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var packages = await venv.PipList();\n}\ncatch (ProcessException e)\n{\n    logger.LogError(e, \"pip list failed: stdout={Out} stderr={Err}\", e.Message);\n    // consider rebuilding the venv: await venv.Setup(existsOk: true);\n}","preventionTips":["Confirm the venv interpreter exists before listing packages","Keep the base embedded Python install in place — pyvenv.cfg references it","Rebuild the venv if its directory was moved, deleted, or partially restored","Close processes holding file locks in site-packages"],"tags":["python","uv","pip-list","process","broken-venv"],"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"}