LykosAI/StabilityMatrix · error · FileNotFoundException
pip not found
Error message
pip not found
What it means
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.
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.
Example fix
// before: assuming pip always exists in the venv
await runner.PipIndex("torch");
// after: guard first, fall back to a uv-backed path
if (!File.Exists(runner.PipPath)) {
await runner.PipInstall(new ProcessArgs("--upgrade", "pip")); // seeds pip via uv
}
await runner.PipIndex("torch"); Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(runner.PipPath)) {
await runner.PipInstall(new ProcessArgs("--upgrade", "pip")); // seed pip via uv
} Type guard
static bool HasPip(UvVenvRunner r) => File.Exists(r.PipPath);
Try / catch
try { await runner.PipIndex(pkg); }
catch (FileNotFoundException ex) { Logger.Error($"pip missing: {ex.FileName}"); await EnsurePipAsync(); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/f8bf5397a5576dbb.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/UvVenvRunner.cs:420
$"pip show returned no output for package '{packageName}': {result.StandardError}"
);
}
return PipShowResult.Parse(result.StandardOutput);
}
/// <summary>
/// Run a pip index command, return result as PipIndexResult.
/// </summary>
public async Task<PipIndexResult?> PipIndex(
string packageName,
string? indexUrl = null,
bool includePrerelease = false
)
{
if (!File.Exists(PipPath))
{
throw new FileNotFoundException("pip not found", PipPath);
}
SetPyvenvCfg(BaseInstall.RootPath);
var args = new ProcessArgsBuilder(
"-m",
"pip",
"index",
"versions",
packageName,
"--no-color",
"--disable-pip-version-check"
);
if (indexUrl is not null)
{
args = args.AddKeyedArgs("--index-url", ["--index-url", indexUrl]);
}View on GitHub (pinned to af93d6ef57)