1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Python】パッケージの依存関係を確認

Last updated at Posted at 2023-07-10

  1. pipdeptreeをインストール
    pip install pipdeptree
    
  2. インストール済みのライブラリすべての依存関係を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"
            }
        ]
    },
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?