[Python] Is there any way to show the dependency trees for pip packages?

Discussão em 'Python' iniciado por Stack, Maio 26, 2025.

  1. Stack

    Stack Membro Participativo

    I have a project with multiple package dependencies, the main requirements being listed in requirements.txt. When I call pip freeze it prints the currently installed packages as plain list. I would prefer to also get their dependency relationships, something like this:

    Flask==0.9
    Jinja2==2.7
    Werkzeug==0.8.3

    Jinja2==2.7

    Werkzeug==0.8.3

    Flask-Admin==1.0.6
    Flask==0.9
    Jinja2==2.7
    Werkzeug==0.8.3


    The goal is to detect the dependencies of each specific package:

    Werkzeug==0.8.3
    Flask==0.9
    Flask-Admin==1.0.6


    And insert these into my current requirements.txt. For example, for this input:

    Flask==0.9
    Flask-Admin==1.0.6
    Werkzeug==0.8.3


    I would like to get:

    Flask==0.9
    Jinja2==2.7
    Flask-Admin==1.0.6
    Werkzeug==0.8.3


    Is there any way show the dependencies of installed pip packages?

    Continue reading...

Compartilhe esta Página