Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
This repository was archived by the owner on Jan 14, 2026. It is now read-only.

[bug] Dependency installer tries to install submodules like matplotlib.pyplot #49

Description

Description

When running Python code that includes imports like import matplotlib.pyplot as plt, the sandbox's dependency installer attempts to install matplotlib.pyplot as if it were a standalone package. This results in errors such as:

Failed to install required Python packages: matplotlib.pyplot. This is likely because these packages are not available in the Pyodide environment.

However, matplotlib.pyplot is a submodule of matplotlib, not a top-level package. Only matplotlib should be installed (or checked for availability).

To Reproduce

  1. Run any Python code in the sandbox environment that includes:
    import matplotlib.pyplot as plt
  2. Observe that the environment attempts to install matplotlib.pyplot and fails.

Expected behavior

The dependency manager should only attempt to install/check top-level packages (the first part of the import, e.g., matplotlib), not submodules (like matplotlib.pyplot).
If the top-level package is present, all submodules should import without additional installation.

Proposed solution

  • When parsing imports and determining which packages to install, extract only the top-level module name (everything before the first .) for installation checks.
  • For example, both import matplotlib.pyplot and import matplotlib should only trigger an install/check for matplotlib.

Example

This code:

import matplotlib.pyplot as plt

should only cause the dependency resolver to check for or install matplotlib.

Additional context

This behavior breaks standard Python workflows where submodules are routinely imported. It also prevents plotting with matplotlib in environments that otherwise support it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions