pyodide-kernel icon indicating copy to clipboard operation
pyodide-kernel copied to clipboard

%pip install magic with inline comment causes InvalidRequirement error

Open ArturoAmorQ opened this issue 5 months ago • 1 comments

Description

When using JupyterLite, adding an inline comment to a %pip install line e.g.:

%pip install seaborn # comment

the comment is interpreted as part of the package list, resulting in an InvalidRequirement error.

The behavior appears inconsistently across browsers — for example, it fails in Brave (Chromium-based) but not in Chrome.

Reproduce

  1. Launch a JupyterLite notebook (e.g., from https://jupyterlite.github.io/demo).

  2. In a code cell, enter the following line: %pip install seaborn # required to use seaborn in jupyterlite

  3. Run the cell.

Expected behavior

The magic command parser strips the inline comments before passing the arguments to piplite, in this case resulting in seaborn being installed no matter the browser.

Context

  • JupyterLite version: latest (from https://jupyterlite.github.io/demo as of 03-07-2025)
  • Operating System and version: Ubuntu 24.04.2 LTS
  • Browser and version: Firefox 139.0.4 (64-bit)
Browser Output
Paste the output from your browser Javascript console here.

ArturoAmorQ avatar Jul 03 '25 09:07 ArturoAmorQ

Thanks @ArturoAmorQ for the report 👍

Looks like it's specific to the Pyodide kernel repo, so moving the issue over there: https://github.com/jupyterlite/pyodide-kernel

jtpio avatar Jul 04 '25 13:07 jtpio