From d43e66ee66aa663bb44b2b21c5e468fb931be555 Mon Sep 17 00:00:00 2001 From: bschnurr Date: Tue, 12 Nov 2024 17:05:52 -0800 Subject: [PATCH] fix for msft python failing to detect pip packages due to pip needing to be updated. in the StandardErrorLines it returns: "[notice] A new release of pip is available: 23.0.1 -> 24.3.1" "[notice] To update, run: C:\\Users\\bschnurr\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe -m pip install --upgrade pip" now we check for no packages found and error strings. if so we just set packages to null and it falls back to directory search to display instead. --- .../VSInterpreters/PackageManager/PipPackageManager.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Python/Product/VSInterpreters/PackageManager/PipPackageManager.cs b/Python/Product/VSInterpreters/PackageManager/PipPackageManager.cs index 5303011bb8..fe6cf71552 100644 --- a/Python/Product/VSInterpreters/PackageManager/PipPackageManager.cs +++ b/Python/Product/VSInterpreters/PackageManager/PipPackageManager.cs @@ -444,6 +444,15 @@ CancellationToken cancellationToken .Where(p => p.IsValid) .OrderBy(p => p.Name) .ToList(); + + + if(packages.Count() == 0 && proc.StandardErrorLines.Any()) { + Debug.WriteLine("Failed to run pip to collect packages"); + foreach (var line in proc.StandardErrorLines) { + Debug.WriteLine(line); + } + packages = null; + } } catch (JsonException ex) { Debug.WriteLine("Failed to parse: {0}".FormatInvariant(ex.Message)); foreach (var l in proc.StandardOutputLines) {