LykosAI/StabilityMatrix · error · FormatException
The 'Name' key was not found in the pip show output.
Error message
The 'Name' key was not found in the pip show output.
What it means
PipShowResult.Parse converts 'pip show' text output into a structured record by parsing 'Key: Value' lines. It requires at minimum a 'Name' key; if the output has no Name line, the output is not valid pip show output and a FormatException is thrown. This protects downstream consumers from a half-populated result.
Solutions
- Verify the package is installed ('pip show <name>' succeeded) before parsing the output
- Check that the string passed to Parse is stdout of pip show, not stderr or warning text
- Check the first parsed line — a WARNING or ERROR line means pip did not emit package data
- Handle FormatException and fall back to checking 'pip list' or exit codes
Example fix
// before
var result = PipShowResult.Parse(processResult.StandardOutput); // may be a WARNING line
// after
if (!processResult.ExitCodeIsZero || !processResult.StandardOutput.StartsWith("Name:"))
throw new InvalidOperationException("Package not installed");
var result = PipShowResult.Parse(processResult.StandardOutput); Defensive patterns
Strategy: try-catch
Validate before calling
if (string.IsNullOrWhiteSpace(output) || !output.Contains("Name:"))
throw new InvalidOperationException("Not valid pip show output (package likely not installed)"); Try / catch
try
{
var result = PipShowResult.Parse(output);
}
catch (FormatException ex)
{
logger.LogWarning(ex, "pip show output missing Name key; package may not be installed");
return null;
} Prevention
- Check the pip process exit code before parsing stdout
- Never parse stderr or combined output as pip show data
- Treat WARNING/ERROR first lines as a signal not to parse
When it happens
Trigger: Passing the stdout of 'pip show <pkg>' to PipShowResult.Parse when the output lacks a 'Name:' line — typically because pip printed a warning/error message instead of package metadata (package not installed).
Common situations: Running pip show for a package that is not installed (pip prints 'WARNING: Package(s) not found'), parsing stderr or combined output, pip output format changes or locale differences.
Related errors
- The 'Version' key was not found in the pip show output.
- Expected opening brace.
- Fields line not found
- get-pip not found
- Install script failed with exit code
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/cc53e6a4952153bc.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/PipShowResult.cs:69
var split = line.Split(':', 2);
if (split.Length != 2)
continue;
var key = split[0].Trim();
var value = split[1].Trim();
if (key == "Name" && linesDict.ContainsKey("Name"))
{
// We've hit a new package, so stop parsing
break;
}
linesDict.TryAdd(key, value);
}
if (!linesDict.TryGetValue("Name", out var name))
{
throw new FormatException("The 'Name' key was not found in the pip show output.");
}
if (!linesDict.TryGetValue("Version", out var version))
{
throw new FormatException("The 'Version' key was not found in the pip show output.");
}
return new PipShowResult
{
Name = name,
Version = version,
Summary = linesDict.GetValueOrDefault("Summary"),
HomePage = linesDict.GetValueOrDefault("Home-page"),
Author = linesDict.GetValueOrDefault("Author"),
AuthorEmail = linesDict.GetValueOrDefault("Author-email"),
License = licenseText,
Location = linesDict.GetValueOrDefault("Location"),
Requires = linesDictView on GitHub (pinned to af93d6ef57)