LykosAI/StabilityMatrix · error · Exception
Python download did not contain expected inner 'python'…
Error message
Python {version} download did not contain expected inner 'python' folder: {innerPythonDir} What it means
After extracting the Python archive on Unix, InstallPythonIfNecessary expects an inner 'python' folder inside the extraction target and moves its contents up to PythonDir. If that folder is missing the archive layout is not what the app expects, so a plain Exception is thrown with the checked path.
Solutions
- Delete the python install directory under Assets and reinstall Python so extraction starts clean.
- Re-download the archive (fix hash-mismatch/network issues first) so the correct layout is extracted.
- Free disk space if extraction is being truncated.
- Update Stability Matrix if the asset layout changed and the bundled extractor expects the old layout.
Defensive patterns
Strategy: validation
Validate before calling
var inner = pythonDir.JoinDir("python");
if (!inner.Exists) { /* clean extraction dir and reinstall before proceeding */ Directory.Delete(pythonDir, true); } Try / catch
try { await helper.InstallPythonIfNecessary(version); }
catch (Exception ex) when (ex.Message.Contains("inner 'python' folder"))
{ Directory.Delete(pythonDir, true); await helper.InstallPythonIfNecessary(version); } Prevention
- Always start extraction from a clean target directory (remove stale python dirs).
- Verify the archive hash first so broken downloads are never extracted.
- Don't manually unpack or modify the assets python directory.
- Keep enough free disk space for full extraction.
When it happens
Trigger: The extracted python-{version} directory does not contain a top-level 'python' folder — extraction was interrupted/partial, the downloaded archive has a different layout, or the target pythonDir already contains stale/partial content.
Common situations: Disk full during extraction; leftover partial extraction from a previously failed install; app version expecting layout X but assets serving layout Y; user manually unpacked/modified the assets directory.
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
- Python was not found and/or failed to install. Please check…
- Unsupported Python version
- Python download hash mismatch: expected , actual
- Torch is not installed in the virtual environment.
- No compatible torch version found in the virtual…
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/c89e1a6eccc5997a.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs:362
);
}
// Extract
Logger.Info($"Extracting Python {version} Zip: {downloadPath} to {pythonDir}");
if (pythonDir.Exists)
{
await pythonDir.DeleteAsync(true);
}
progress?.Report(new ProgressReport(0, $"Installing Python {version}", isIndeterminate: true));
await ArchiveHelper.Extract7ZAuto(downloadPath, pythonDir);
// For Unix, move the inner 'python' folder up to the root PythonDir
if (Compat.IsUnix)
{
var innerPythonDir = pythonDir.JoinDir("python");
if (!innerPythonDir.Exists)
{
throw new Exception(
$"Python {version} download did not contain expected inner 'python' folder: {innerPythonDir}"
);
}
foreach (var folder in Directory.EnumerateDirectories(innerPythonDir))
{
var folderName = Path.GetFileName(folder);
var dest = Path.Combine(pythonDir, folderName);
Directory.Move(folder, dest);
}
Directory.Delete(innerPythonDir);
}
}
finally
{
// Cleanup download file
if (File.Exists(downloadPath))
{View on GitHub (pinned to af93d6ef57)