Skip to content

Option --exclude does not exclude the dependencies from the output #452

@Felixoid

Description

@Felixoid

What pipdeptree version are you using?

2.25.0

Are you running pipdeptree in a virtual environment?

No

Describe the problem

According to #69, the --exclude should behave as a filter to remove all the dependencies. Currently, it doesn't work like that, putting the dependencies at the top level. Here are examples:

# pipdeptree --path /usr/local/lib/python*/dist-packages/
pipdeptree==2.25.0
├── packaging [required: >=24.1, installed: 24.2]
└── pip [required: >=24.2, installed: 25.0.1]
pytest-random-order==1.1.1
└── pytest [required: >=3.0.0, installed: 8.3.4]
    ├── exceptiongroup [required: >=1.0.0rc8, installed: 1.2.2]
    ├── iniconfig [required: Any, installed: 2.0.0]
    ├── packaging [required: Any, installed: 24.2]
    ├── pluggy [required: >=1.5,<2, installed: 1.5.0]
    └── tomli [required: >=1, installed: 2.2.1]
# pipdeptree --path /usr/local/lib/python*/dist-packages/ --exclude pipdeptree
pip==25.0.1
pytest-random-order==1.1.1
└── pytest [required: >=3.0.0, installed: 8.3.4]
    ├── exceptiongroup [required: >=1.0.0rc8, installed: 1.2.2]
    ├── iniconfig [required: Any, installed: 2.0.0]
    ├── packaging [required: Any, installed: 24.2]
    ├── pluggy [required: >=1.5,<2, installed: 1.5.0]
    └── tomli [required: >=1, installed: 2.2.1]
# pipdeptree --path /usr/local/lib/python*/dist-packages/ --freeze
pipdeptree==2.25.0
  packaging==24.2
  pip==25.0.1
pytest-random-order==1.1.1
  pytest==8.3.4
    exceptiongroup==1.2.2
    iniconfig==2.0.0
    packaging==24.2
    pluggy==1.5.0
    tomli==2.2.1
# pipdeptree --path /usr/local/lib/python*/dist-packages/ --freeze --exclude pipdeptree
pip==25.0.1
pytest-random-order==1.1.1
  pytest==8.3.4
    exceptiongroup==1.2.2
    iniconfig==2.0.0
    packaging==24.2
    pluggy==1.5.0
    tomli==2.2.1

The pip was installed as a dependency for pipdeptree:

# pip install pipdeptree
Collecting pipdeptree
  Downloading pipdeptree-2.25.0-py3-none-any.whl (32 kB)
Requirement already satisfied: packaging>=24.1 in /usr/local/lib/python3.10/dist-packages (from pipdeptree) (24.2)
Collecting pip>=24.2
  Downloading pip-25.0.1-py3-none-any.whl (1.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 9.8 MB/s eta 0:00:00
Installing collected packages: pip, pipdeptree
  Attempting uninstall: pip
    Found existing installation: pip 22.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-25.0.1 pipdeptree-2.25.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtobeconfirmedTo be confirmed after more investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions