Identifying the dependency relationship for python packages installed with pip

前端 未结 8 672
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 16:20

When I do a pip freeze I see large number of Python packages that I didn\'t explicitly install, e.g.

$ pip freeze
Cheetah==2.4.3
GnuPGInterface==0.3.2
Landsc         


        
8条回答
  •  醉话见心
    2020-11-29 16:47

    You could try pipdeptree which displays dependencies as a tree structure e.g.:

    $ pipdeptree
    Lookupy==0.1
    wsgiref==0.1.2
    argparse==1.2.1
    psycopg2==2.5.2
    Flask-Script==0.6.6
      - Flask [installed: 0.10.1]
        - Werkzeug [required: >=0.7, installed: 0.9.4]
        - Jinja2 [required: >=2.4, installed: 2.7.2]
          - MarkupSafe [installed: 0.18]
        - itsdangerous [required: >=0.21, installed: 0.23]
    alembic==0.6.2
      - SQLAlchemy [required: >=0.7.3, installed: 0.9.1]
      - Mako [installed: 0.9.1]
        - MarkupSafe [required: >=0.9.2, installed: 0.18]
    ipython==2.0.0
    slugify==0.0.1
    redis==2.9.1
    

    To get it run:

    pip install pipdeptree
    


    EDIT: as noted by @Esteban in the comments you can also list the tree in reverse with -r or for a single package with -p so to find what installed Werkzeug you could run:

    $ pipdeptree -r -p Werkzeug
    Werkzeug==0.11.15
      - Flask==0.12 [requires: Werkzeug>=0.7]
    

提交回复
热议问题