Skip to content

Package list shows "No packages found" when pip emits an upgrade notice (JSON parse failure) #1650

Description

@eleanorjboyd

The Python Environments sidebar reports "No packages found" for a venv that actually has packages installed. The root cause is that the extension parses pip list --format=json output as JSON, but older pip versions append a [notice] A new release of pip is available... message to stdout after the JSON array, which breaks parsing.

Environment:

  • Python Envs extension version: 1.37.2026070201
  • OS: macOS
  • Env type: venv (ms-python.python:venv)
  • Python: 3.10.20
  • pip: 23.0.1 (bundled; emits upgrade notice to stdout)

Steps to reproduce:

  1. Create/select a venv whose pip is outdated enough to print an upgrade notice (e.g. pip 23.0.1).
  2. Install one or more packages (e.g. pytest).
  3. Open the Python Environments sidebar and click the environment.

Expected behavior:
The installed packages (pytest, pluggy, iniconfig, etc.) are listed.

Actual behavior:
The sidebar shows "No packages found." The output log shows the package refresh failing to parse JSON:

Running: .../.venv/bin/python -m pip list --format=json
python: [{"name": "pip", "version": "23.0.1"}, {"name": "setuptools", "version": "79.0.1"}]
python:
[notice] A new release of pip is available: 23.0.1 -> 26.1.2
[notice] To update, run: .../.venv/bin/python -m pip install --upgrade pip
Failed to parse pip list JSON output Unexpected non-whitespace character after JSON at position 85 (line 3 column 1)

The packages are genuinely installed — a manual pip list confirms pytest 9.1.1 and its dependencies are present. Only the extension's parsing fails.

Additional related symptoms (same root cause):

  • A "problem installing packages" notification can appear even when the install itself succeeds, because the post-install package refresh fails to parse.
  • Transient No module named pip errors immediately after in-place venv recreation (python3.10 -m venv .venv), before pip is bootstrapped, trigger the same refresh failure path.

Suggested fix:
Make the pip-list parser robust to non-JSON trailing output. Options:

  • Extract only the JSON array/object from stdout before parsing (e.g. slice from the first [/{ to its matching close), rather than JSON.parse(entireStdout).
  • Run pip with --disable-pip-version-check (and/or PIP_DISABLE_PIP_VERSION_CHECK=1) when listing packages to suppress the notice.
  • Pass --no-python-version-warning / route notices to stderr where feasible.

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugtriage-needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions