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

  1. Delete the python install directory under Assets and reinstall Python so extraction starts clean.
  2. Re-download the archive (fix hash-mismatch/network issues first) so the correct layout is extracted.
  3. Free disk space if extraction is being truncated.
  4. 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

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


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)