LykosAI/StabilityMatrix · error · FileNotFoundException
pip not found
Error message
pip not found
What it means
PipInstall() throws FileNotFoundException when the venv's pip executable (PipPath, e.g. Scripts/pip.exe or bin/pip) does not exist. The library will not spawn a pip command without a working pip inside the venv. Usually means the venv was created without pip or was never fully initialized.
Solutions
- Recreate the venv via Setup() ensuring pip is included (no --without-pip).
- Run `python -m ensurepip` against the venv interpreter to restore pip.
- Verify PipPath exists before calling: File.Exists(venvRunner.PipPath).
- Confirm RootPath and BaseInstall point at the intended, intact venv.
Example fix
// before
await venvRunner.PipInstall("numpy");
// after
if (!File.Exists(venvRunner.PipPath))
{
await venvRunner.Setup(null, null, ct); // recreate venv with pip
}
await venvRunner.PipInstall("numpy"); Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(venvRunner.PipPath))
{
await venvRunner.Setup(null, null, ct);
} Try / catch
catch (FileNotFoundException e) when (e.FileName == venvRunner.PipPath)
{
// recreate venv, then retry the pip operation
} Prevention
- Create venvs with pip included (never --without-pip).
- Check PipPath existence as a preflight before batch pip operations.
- Avoid uninstalling pip itself from the venv.
When it happens
Trigger: Calling PipInstall() on a venv created without pip (e.g. `python -m venv --without-pip`), a venv whose creation failed partway, or a PyVenvRunner whose RootPath/PythonPath configuration points to a venv lacking pip.
Common situations: Venv created with pip omitted; pip later uninstalled from the venv; corrupted/incomplete venv after failed setup or interrupted upgrade; wrong RootPath pointing to a non-venv folder.
Related errors
- get-pip not found
- pip not found
- pip not found
- Python installation not found at
- Python linked library not found
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/0340d924d11573db.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/PyVenvRunner.cs:228
cfg["home"] = pythonDirectory;
cfg["base-prefix"] = pythonDirectory;
cfg["base-exec-prefix"] = pythonDirectory;
cfg["base-executable"] = baseExecutable;
cfg.Save(cfgPath);
// Update last set path
lastSetPyvenvCfgPath = pythonDirectory;
}
/// <summary>
/// Run a pip install command. Waits for the process to exit.
/// workingDirectory defaults to RootPath.
/// </summary>
public async Task PipInstall(ProcessArgs args, Action<ProcessOutput>? outputDataReceived = null)
{
if (!File.Exists(PipPath))
{
throw new FileNotFoundException("pip not found", PipPath);
}
// Record output for errors
var output = new StringBuilder();
var outputAction = new Action<ProcessOutput>(s =>
{
Logger.Debug($"Pip output: {s.Text}");
// Record to output
output.Append(s.Text);
// Forward to callback
outputDataReceived?.Invoke(s);
});
RunDetached(args.Prepend("-m pip install").Concat("--exists-action s"), outputAction);
await Process.WaitForExitAsync().ConfigureAwait(false);
// Check return codeView on GitHub (pinned to af93d6ef57)