查看已安装的Python包依赖树
生活随笔
收集整理的這篇文章主要介紹了
查看已安装的Python包依赖树
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
如有侵權(quán),請聯(lián)系作者。
轉(zhuǎn)載請注明出處。
幫助他人,記錄自己。
目錄
- 標(biāo)簽
- 修訂歷史
- 說明
- 使用
- 安裝 pipdeptree
- 查看 pipdeptree 版本
- 直接使用
- 用 freeze 格式顯示依賴樹
- 顯示所有包的依賴樹,包括依賴包和被依賴包
- 反轉(zhuǎn)依賴樹
- 只顯示某些包的依賴樹
- 不顯示某些包的依賴樹
- 使用 Json 格式顯示所有包的依賴樹,包括依賴包和被依賴包
- 使用 Json 格式只顯示頂層依賴樹,不包括被依賴包的依賴樹
- 使用“幫助”獲取更多詳細(xì)信息
標(biāo)簽
Python 依賴管理,Python 包管理,Python,依賴管理,包管理,依賴樹,依賴信息,pip,pipdeptree。
修訂歷史
- 2020-04-24:首次編輯。
說明
Python 雖然有虛擬環(huán)境(virtualenv)工具可以方便管理項目之間的依賴,但是項目內(nèi)的依賴樹依然有些混亂,如果有類似 Java 中 Maven 的 dependency tree 可以一鍵查看所有依賴樹信息就好了。于是在網(wǎng)上找到一款可以方便查看 Python 已安裝包的依賴樹信息查看工具 pipdeptree。使用方法如下:
使用
安裝 pipdeptree
(temp-test) [adam@ZCY ~]$ pip install pipdeptreeLooking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting pipdeptreeDownloading http://mirrors.aliyun.com/pypi/packages/12/64/26c7df3ad833cd6e8b9735c5958b25d6aef1617c915b2731baedfbeee712/pipdeptree-0.13.2-py3-none-any.whl (16 kB) Requirement already satisfied: pip>=6.0.0 in ./virtualenv/temp-test/lib/python3.6/site-packages (from pipdeptree) (20.0.2) Installing collected packages: pipdeptree Successfully installed pipdeptree-0.13.2查看 pipdeptree 版本
(temp-test) [adam@ZCY ~]$ pipdeptree -v0.13.2直接使用
(temp-test) [adam@ZCY ~]$ pipdeptreeDjango==2.2.12- pytz [required: Any, installed: 2019.3]- sqlparse [required: Any, installed: 0.3.1] pipdeptree==0.13.2- pip [required: >=6.0.0, installed: 20.0.2] setuptools==45.2.0 wheel==0.34.2用 freeze 格式顯示依賴樹
(temp-test) [adam@ZCY ~]$ pipdeptree -fDjango==2.2.12pytz==2019.3sqlparse==0.3.1 pipdeptree==0.13.2pip==20.0.2 setuptools==45.2.0 wheel==0.34.2顯示所有包的依賴樹,包括依賴包和被依賴包
(temp-test) [adam@ZCY ~]$ pipdeptree -aDjango==2.2.12- pytz [required: Any, installed: 2019.3]- sqlparse [required: Any, installed: 0.3.1] pip==20.0.2 pipdeptree==0.13.2- pip [required: >=6.0.0, installed: 20.0.2] pytz==2019.3 setuptools==45.2.0 sqlparse==0.3.1 wheel==0.34.2反轉(zhuǎn)依賴樹
(temp-test) [adam@ZCY ~]$ pipdeptree -rpip==20.0.2- pipdeptree==0.13.2 [requires: pip>=6.0.0] pytz==2019.3- Django==2.2.12 [requires: pytz] setuptools==45.2.0 sqlparse==0.3.1- Django==2.2.12 [requires: sqlparse] wheel==0.34.2只顯示某些包的依賴樹
(temp-test) [adam@ZCY ~]$ pipdeptree -p djangoDjango==2.2.12- pytz [required: Any, installed: 2019.3]- sqlparse [required: Any, installed: 0.3.1]不顯示某些包的依賴樹
(temp-test) [adam@ZCY ~]$ pipdeptree -e djangopipdeptree==0.13.2- pip [required: >=6.0.0, installed: 20.0.2] setuptools==45.2.0 wheel==0.34.2使用 Json 格式顯示所有包的依賴樹,包括依賴包和被依賴包
(temp-test) [adam@ZCY ~]$ pipdeptree -j[{"package": {"key": "wheel","package_name": "wheel","installed_version": "0.34.2"},"dependencies": []},{"package": {"key": "sqlparse","package_name": "sqlparse","installed_version": "0.3.1"},"dependencies": []},{"package": {"key": "setuptools","package_name": "setuptools","installed_version": "45.2.0"},"dependencies": []},{"package": {"key": "pytz","package_name": "pytz","installed_version": "2019.3"},"dependencies": []},{"package": {"key": "pipdeptree","package_name": "pipdeptree","installed_version": "0.13.2"},"dependencies": [{"key": "pip","package_name": "pip","installed_version": "20.0.2","required_version": ">=6.0.0"}]},{"package": {"key": "pip","package_name": "pip","installed_version": "20.0.2"},"dependencies": []},{"package": {"key": "django","package_name": "Django","installed_version": "2.2.12"},"dependencies": [{"key": "sqlparse","package_name": "sqlparse","installed_version": "0.3.1","required_version": null},{"key": "pytz","package_name": "pytz","installed_version": "2019.3","required_version": null}]} ]使用 Json 格式只顯示頂層依賴樹,不包括被依賴包的依賴樹
(temp-test) [adam@ZCY ~]$ pipdeptree --json-tree[{"key": "django","package_name": "Django","installed_version": "2.2.12","required_version": "2.2.12","dependencies": [{"key": "pytz","package_name": "pytz","installed_version": "2019.3","required_version": "Any","dependencies": []},{"key": "sqlparse","package_name": "sqlparse","installed_version": "0.3.1","required_version": "Any","dependencies": []}]},{"key": "pipdeptree","package_name": "pipdeptree","installed_version": "0.13.2","required_version": "0.13.2","dependencies": [{"key": "pip","package_name": "pip","installed_version": "20.0.2","required_version": ">=6.0.0","dependencies": []}]},{"key": "setuptools","package_name": "setuptools","installed_version": "45.2.0","required_version": "45.2.0","dependencies": []},{"key": "wheel","package_name": "wheel","installed_version": "0.34.2","required_version": "0.34.2","dependencies": []} ]使用“幫助”獲取更多詳細(xì)信息
(temp-test) [adam@ZCY ~]$ pipdeptree -husage: pipdeptree [-h] [-v] [-f] [-a] [-l] [-u] [-w [{silence,suppress,fail}]][-r] [-p PACKAGES] [-e PACKAGES] [-j] [--json-tree][--graph-output OUTPUT_FORMAT]Dependency tree of the installed python packagesoptional arguments:-h, --help show this help message and exit-v, --version show program's version number and exit-f, --freeze Print names so as to write freeze files-a, --all list all deps at top level-l, --local-only If in a virtualenv that has global access do not showglobally installed packages-u, --user-only Only show installations in the user site dir-w [{silence,suppress,fail}], --warn [{silence,suppress,fail}]Warning control. "suppress" will show warnings butreturn 0 whether or not they are present. "silence"will not show warnings at all and always return 0."fail" will show warnings and return 1 if any arepresent. The default is "suppress".-r, --reverse Shows the dependency tree in the reverse fashion ie.the sub-dependencies are listed with the list ofpackages that need them under them.-p PACKAGES, --packages PACKAGESComma separated list of select packages to show in theoutput. If set, --all will be ignored.-e PACKAGES, --exclude PACKAGESComma separated list of select packages to excludefrom the output. If set, --all will be ignored.-j, --json Display dependency tree as json. This will yield "raw"output that may be used by external tools. This optionoverrides all other options.--json-tree Display dependency tree as json which is nested thesame way as the plain text output printed by default.This option overrides all other options (except--json).--graph-output OUTPUT_FORMATPrint a dependency graph in the specified outputformat. Available are all formats supported byGraphViz, e.g.: dot, jpeg, pdf, png, svg總結(jié)
以上是生活随笔為你收集整理的查看已安装的Python包依赖树的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java 8 stream学习
- 下一篇: js实现touch移动触屏滑动事件