- pipdeptreeをインストール
pip install pipdeptree
- インストール済みのライブラリすべての依存関係をJSON形式で出力
pipdeptree --json > out.txt
PyTorchの依存関係だとこんな感じ
{
"package": {
"key": "torch",
"package_name": "torch",
"installed_version": "2.0.1+cu117"
},
"dependencies": [
{
"key": "filelock",
"package_name": "filelock",
"installed_version": "3.8.2",
"required_version": null
},
{
"key": "jinja2",
"package_name": "Jinja2",
"installed_version": "3.1.2",
"required_version": null
},
{
"key": "networkx",
"package_name": "networkx",
"installed_version": "3.0",
"required_version": null
},
{
"key": "sympy",
"package_name": "sympy",
"installed_version": "1.11.1",
"required_version": null
},
{
"key": "typing-extensions",
"package_name": "typing-extensions",
"installed_version": "4.4.0",
"required_version": null
}
]
},
{
"package": {
"key": "torchaudio",
"package_name": "torchaudio",
"installed_version": "2.0.2+cu117"
},
"dependencies": [
{
"key": "torch",
"package_name": "torch",
"installed_version": "2.0.1+cu117",
"required_version": "==2.0.1"
}
]
},
{
"package": {
"key": "torchvision",
"package_name": "torchvision",
"installed_version": "0.15.2+cu117"
},
"dependencies": [
{
"key": "numpy",
"package_name": "numpy",
"installed_version": "1.23.5",
"required_version": null
},
{
"key": "pillow",
"package_name": "Pillow",
"installed_version": "9.3.0",
"required_version": ">=5.3.0,!=8.3.*"
},
{
"key": "requests",
"package_name": "requests",
"installed_version": "2.28.1",
"required_version": null
},
{
"key": "torch",
"package_name": "torch",
"installed_version": "2.0.1+cu117",
"required_version": "==2.0.1"
}
]
},