识别与pip一起安装的python软件包的依赖关系 [英] Identifying the dependency relationship for python packages installed with pip
问题描述
冻结点时,我看到大量未明确安装的Python软件包,例如
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
Landscape-Client==11.01
M2Crypto==0.20.1
PAM==0.4.2
PIL==1.1.7
PyYAML==3.09
Twisted-Core==10.2.0
Twisted-Web==10.2.0
(etc.)
我是否可以确定为什么pip安装了这些特定的依赖软件包?换句话说,如何确定将这些软件包作为依赖项的父软件包?
Is there a way for me to determine why pip installed these particular dependent packages? In other words, how do I determine the parent package that had these packages as dependencies?
例如,我可能想使用Twisted,并且在我不了解不意外卸载或升级它之前,不要依赖于某个软件包.
For example, I might want to use Twisted and I don't want to depend on a package until I know more about not accidentally uninstalling it or upgrading it.
推荐答案
您可以尝试显示的 pipdeptree 依赖关系作为树结构,例如:
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
要使其运行:
pip install pipdeptree
,如@Esteban在注释中所指出的,您还可以用-r
反向列出树,或者用-p <package_name>
列出单个软件包,以便找到可以运行的安装的Werkzeug:>
as noted by @Esteban in the comments you can also list the tree in reverse with -r
or for a single package with -p <package_name>
so to find what installed Werkzeug you could run:
$ pipdeptree -r -p Werkzeug
Werkzeug==0.11.15
- Flask==0.12 [requires: Werkzeug>=0.7]
这篇关于识别与pip一起安装的python软件包的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!