LykosAI/StabilityMatrix · error · ProcessException
Venv creation failed with code
Error message
Venv creation failed with code {venvProc.ExitCode} What it means
Setup() launches `python -m venv` as a subprocess and throws ProcessException if the venv creation process exits with a non-zero exit code. This means the Python interpreter failed to build the virtual environment (bad interpreter, corrupted base install, disk/permission problems).
Solutions
- Inspect captured console output (onConsoleOutput) for the underlying Python error message.
- Delete the partially created venv directory, re-download/reinstall the base Python (PyInstall), and retry Setup.
- Verify the base Python executable runs standalone: `<basePython> --version`.
- Free disk space and check no processes hold locks on the venv directory (Windows).
Defensive patterns
Strategy: try-catch
Validate before calling
if (!File.Exists(baseInstall.PythonPath)) throw new InvalidOperationException("Base Python missing"); Try / catch
catch (ProcessException e)
{
Logger.Error("venv creation failed: {Msg}", e.Message);
await venvRunner.DeleteAsync(ct); // clean partial state
throw;
} Prevention
- Verify the base Python install is complete before Setup (executable exists and runs).
- Log onConsoleOutput so the underlying pip/python error is captured.
- Ensure adequate free disk space before provisioning.
When it happens
Trigger: Calling Setup() when the base Python executable is broken/incompatible (e.g. mismatched embedded Python version), the target disk is full, or antivirus blocks venv creation, causing the venv subprocess to return non-zero.
Common situations: Corrupted or half-deleted base Python install (BaseInstall path changed after upgrade); insufficient disk space; Windows file locks on python.exe from a previous process; embedded Python download incomplete.
Related errors
- Venv creation failed with code
- pip show failed with code
- Venv python not found
- Torch is not installed in the virtual environment.
- ComfyUI venv was not found at
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/e50ff25f2d304d49.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Python/PyVenvRunner.cs:167
// Create venv (copy mode if windows)
var args = new string[] { "-m", "virtualenv", Compat.IsWindows ? "--always-copy" : "", RootPath };
var venvProc = ProcessRunner.StartAnsiProcess(
BaseInstall.PythonExePath,
args,
WorkingDirectory?.FullPath,
onConsoleOutput
);
try
{
await venvProc.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
// Check return code
if (venvProc.ExitCode != 0)
{
throw new ProcessException($"Venv creation failed with code {venvProc.ExitCode}");
}
}
catch (OperationCanceledException)
{
venvProc.CancelStreamReaders();
}
finally
{
venvProc.Kill();
venvProc.Dispose();
}
}
/// <summary>
/// Set current python path to pyvenv.cfg
/// This should be called before using the venv, in case user moves the venv directory.
/// </summary>
private void SetPyvenvCfg(string pythonDirectory, bool force = false)View on GitHub (pinned to af93d6ef57)