Skip to content

Feature Request: Add pip list-deps to inspect dependencies of uninstalled packages. #14183

Description

@human-on-vm

What's the problem this feature will solve?

Currently, there is no native, straightforward way to inspect the full dependency tree of a package before installing it. The standard workaround is to use pip install <package> --dry-run. However, using --dry-run for this purpose is fundamentally flawed for several reasons:

  1. Environment Coupling: --dry-run simulates an installation for the current local environment. It resolves dependencies against what is already installed locally. If a user wants to know "What does package X require?", --dry-run actually answers "What would pip need to download for my specific machine right now to satisfy this package?". This makes it impossible to get a pure, environment-agnostic view of a package's dependency tree.
  2. Performance and Overhead: Because --dry-run performs a full installation simulation, it checks local environment states, verifies hashes, and resolves conflicts with existing packages. This makes it unnecessarily slow if the only goal is to read the package's metadata and dependency tree from the index.
  3. Output Format: The output of --dry-run is formatted to show what would be downloaded or installed (e.g., Would install package-a-1.0 package-b-2.0). It is not optimized to display a clean, hierarchical, or easily parsable list of dependencies.

Describe the solution you'd like

I propose adding a dedicated command or flag, such as pip list-deps <package> (or pip show --deps <package> for not installed packages), specifically designed to list the dependencies of a package directly from the package index without simulating a local installation.

Key characteristics of this feature should include:

  • Environment-Agnostic Resolution: It should show what the package requires, not what the local environment lacks. It could optionally accept flags like --python-version or --platform to resolve environment-specific dependencies without needing a local virtualenv.
  • Speed: By skipping local environment resolution and hash checking, it should be significantly faster than --dry-run.
  • Clean & Parsable Output: The output should be a clean list or tree of dependencies. Adding a --json or --format flag would make it easily parsable for CI/CD pipelines and scripting.

Alternative Solutions

  • Using pip install --dry-run: As mentioned, this is environment-coupled, slow, and outputs data in a format meant for installation simulation, not dependency inspection.
  • Using third-party tools (e.g., johnnydep, pipgrip): While these tools solve the problem, they require users to install and maintain additional third-party packages. Having this natively in pip would provide a standardized, zero-dependency experience for all users.
  • Creating a temporary virtual environment: Users can create a throwaway venv, run pip install, and then use pip freeze or pipdeptree. This is highly manual, slow, and not suitable for scripting or quick checks.
  • Checking the PyPI website manually: The web interface only shows direct dependencies, not the full transitive tree, and cannot be easily scripted.

Additional context

This feature would greatly improve the developer experience for several common workflows:

  • Security Auditing: Quickly checking the transitive dependency tree of a package before adding it to a project to look for known vulnerabilities.
  • Size/Scope Estimation: Understanding how "heavy" a package is before committing to installing it in constrained environments (like Docker images, AWS Lambda, or embedded systems).
  • Scripting and Automation: Easily extracting a list of dependencies for a package to feed into other tools, without having to parse the verbose output of --dry-run.

Ultimately, adding a list-deps command would separate the concern of inspecting package metadata from simulating environment mutations, resulting in a cleaner and more intuitive CLI.

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions