{"record":{"id":"f8bf5397a5576dbb","repo":"LykosAI/StabilityMatrix","slug":"pip-not-found-uvvenvrunner","errorCode":null,"errorMessage":"pip not found","messagePattern":"pip not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/UvVenvRunner.cs","lineNumber":420,"sourceCode":"                $\"pip show returned no output for package '{packageName}': {result.StandardError}\"\n            );\n        }\n\n        return PipShowResult.Parse(result.StandardOutput);\n    }\n\n    /// <summary>\n    /// Run a pip index command, return result as PipIndexResult.\n    /// </summary>\n    public async Task<PipIndexResult?> PipIndex(\n        string packageName,\n        string? indexUrl = null,\n        bool includePrerelease = false\n    )\n    {\n        if (!File.Exists(PipPath))\n        {\n            throw new FileNotFoundException(\"pip not found\", PipPath);\n        }\n\n        SetPyvenvCfg(BaseInstall.RootPath);\n\n        var args = new ProcessArgsBuilder(\n            \"-m\",\n            \"pip\",\n            \"index\",\n            \"versions\",\n            packageName,\n            \"--no-color\",\n            \"--disable-pip-version-check\"\n        );\n\n        if (indexUrl is not null)\n        {\n            args = args.AddKeyedArgs(\"--index-url\", [\"--index-url\", indexUrl]);\n        }","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/UvVenvRunner.cs#L402-L438","documentation":"UvVenvRunner.PipIndex throws FileNotFoundException(\"pip not found\", PipPath) before running `python -m pip index versions` when the pip executable path for the base install does not exist on disk. The library refuses to spawn a process with a missing binary, so this signals the venv/base Python install is incomplete or was never set up.","triggerScenarios":"Calling PipIndex(packageName) when File.Exists(PipPath) is false — the venv's pip script/Scripts path is absent because the venv was created without pip (uv-created venvs often omit pip by default) or the base install is broken/deleted.","commonSituations":"Venvs created via `uv venv` (which does not install pip unless --seed is used); a partially cleaned or moved install directory; wrong BaseInstall pointing at a non-Python directory; platform path differences (Scripts vs bin).","solutions":["Ensure pip exists in the venv: run `uv pip install --python <venvPython> pip` or recreate the venv with seeding.","Use the uv-based PipInstall/PipShow paths (which use UvExecutablePath) instead of PipIndex when the venv has no pip.","Verify BaseInstall.RootPath points at a real Python install and PipPath matches the OS layout (Scripts\\pip.exe on Windows, bin/pip on Unix).","Re-setup the venv via UvVenvRunner if the directory was partially deleted."],"exampleFix":"// before: assuming pip always exists in the venv\nawait runner.PipIndex(\"torch\");\n// after: guard first, fall back to a uv-backed path\nif (!File.Exists(runner.PipPath)) {\n    await runner.PipInstall(new ProcessArgs(\"--upgrade\", \"pip\")); // seeds pip via uv\n}\nawait runner.PipIndex(\"torch\");","handlingStrategy":"validation","validationCode":"if (!File.Exists(runner.PipPath)) {\n    await runner.PipInstall(new ProcessArgs(\"--upgrade\", \"pip\")); // seed pip via uv\n}","typeGuard":"static bool HasPip(UvVenvRunner r) => File.Exists(r.PipPath);","tryCatchPattern":"try { await runner.PipIndex(pkg); }\ncatch (FileNotFoundException ex) { Logger.Error($\"pip missing: {ex.FileName}\"); await EnsurePipAsync(); }","preventionTips":["uv-created venvs omit pip by default; seed pip or prefer uv-based APIs.","Verify PipPath per-OS (Scripts\\pip.exe vs bin/pip) after venv creation.","Guard PipIndex calls with a File.Exists(PipPath) check."],"tags":["python","pip","file-not-found","venv"],"backgroundTag":"file-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"}