{"record":{"id":"ec0ac1db6aa0b50c","repo":"LykosAI/StabilityMatrix","slug":"pip-not-found","errorCode":null,"errorMessage":"pip not found","messagePattern":"pip not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Python/PyRunner.cs","lineNumber":295,"sourceCode":"            .EnsureSuccessExitCode()\n            .ConfigureAwait(false);\n    }\n\n    /// <summary>\n    /// Install a Python package with pip\n    /// </summary>\n    public async Task InstallPackage(string package, PyVersion? version = null)\n    {\n        // Use either the specified version or the current installation\n        var installation =\n            version != null\n                ? await installationManager.GetInstallationAsync(version.Value).ConfigureAwait(false)\n                : currentInstallation\n                    ?? await installationManager.GetDefaultInstallationAsync().ConfigureAwait(false);\n\n        if (!File.Exists(installation.PipExePath))\n        {\n            throw new FileNotFoundException(\"pip not found\", installation.PipExePath);\n        }\n        var result = await ProcessRunner\n            .GetProcessResultAsync(installation.PythonExePath, $\"-m pip install {package}\")\n            .ConfigureAwait(false);\n        result.EnsureSuccessExitCode();\n    }\n\n    /// <summary>\n    /// Run a Function with PyRunning lock as a Task with GIL.\n    /// </summary>\n    /// <param name=\"func\">Function to run.</param>\n    /// <param name=\"waitTimeout\">Time limit for waiting on PyRunning lock.</param>\n    /// <param name=\"cancelToken\">Cancellation token.</param>\n    /// <exception cref=\"OperationCanceledException\">cancelToken was canceled, or waitTimeout expired.</exception>\n    public async Task<T> RunInThreadWithLock<T>(\n        Func<T> func,\n        TimeSpan? waitTimeout = null,\n        CancellationToken cancelToken = default","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Python/PyRunner.cs#L277-L313","documentation":"PyRunner.InstallPackage installs a pip package by shelling out to pip. It checks installation.PipExePath exists first; if the pip executable is missing, a FileNotFoundException with the path is thrown.","triggerScenarios":"Calling InstallPackage on an installation where pip was never installed (SetupPip not run), a venv without pip, or a corrupted environment missing the pip executable.","commonSituations":"Fresh environments created with pip omitted, environments where pip was uninstalled, custom Python distributions without pip, install metadata pointing at a stale PipExePath.","solutions":["Run SetupPip (or 'python -m ensurepip') on the installation to install pip first","Verify installation.PipExePath exists before installing packages","Recreate the venv/environment ensuring pip is included (virtualenv with pip, not --without-pip)","Alternatively invoke 'python -m pip install' via the Python executable as a fallback"],"exampleFix":"// before\nawait pyRunner.InstallPackage(installation, \"numpy\"); // pip missing\n// after\nif (!File.Exists(installation.PipExePath))\n    await pyRunner.SetupPip(installation);\nawait pyRunner.InstallPackage(installation, \"numpy\");","handlingStrategy":"validation","validationCode":"if (!File.Exists(installation.PipExePath))\n    await pyRunner.SetupPip(installation);","typeGuard":null,"tryCatchPattern":"try\n{\n    await pyRunner.InstallPackage(installation, packageName);\n}\ncatch (FileNotFoundException ex)\n{\n    logger.LogError(ex, \"pip missing; bootstrapping\");\n    await pyRunner.SetupPip(installation);\n    await pyRunner.InstallPackage(installation, packageName);\n}","preventionTips":["Run pip setup once after creating any new environment","Create venvs with pip included (never --without-pip)","Verify PipExePath exists before package operations"],"tags":["python","pip","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}