Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pip show" incorrect result for "Required-by" #6947

Svetlitski opened this issue Aug 30, 2019 · 1 comment · Fixed by #6957


Copy link

@Svetlitski Svetlitski commented Aug 30, 2019


  • pip version: 19.2.3
  • Python version: 3.7.4
  • OS: macOS Mojave 10.14.6


Running pip show <package> does not display all dependent packages under "Required-by:", even when <package> shows up in the "Requires:" field of a dependent package.

Expected behavior
Running pip show <package> should show all packages dependent on <package> under the "Required-by:" field of the output.

How to Reproduce

virtualenv pip_show_bug
source pip_show_bug/bin/activate
pip install black
pip show click
pip show black

click is clearly a dependency of black, but black does not show up under "Required-by:" when you run pip show click. All of black's other dependencies (i.e. appdirs, attrs, and toml) behave as expected with pip show, and running pip show black does show click under "Required:"


bash-5.0$ virtualenv pip_show_broken
Using base prefix '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/kevin/pip_show_broken/bin/python3.7
Also creating executable in /Users/kevin/pip_show_broken/bin/python
Installing setuptools, pip, wheel...
bash-5.0$ source pip_show_broken/bin/activate
(pip_show_broken) bash-5.0$ pip install black
Collecting black
  Using cached
Collecting appdirs (from black)
  Using cached
Collecting attrs>=18.1.0 (from black)
  Using cached
Collecting toml>=0.9.4 (from black)
  Using cached
Collecting click>=6.5 (from black)
  Using cached
Installing collected packages: appdirs, attrs, toml, click, black
Successfully installed appdirs-1.4.3 attrs-19.1.0 black-19.3b0 click-7.0 toml-0.10.0
(pip_show_broken) bash-5.0$ pip show click
Name: Click
Version: 7.0
Summary: Composable command line interface toolkit
Author: Armin Ronacher
License: BSD
Location: /Users/kevin/pip_show_broken/lib/python3.7/site-packages
(pip_show_broken) bash-5.0$ pip show black
Name: black
Version: 19.3b0
Summary: The uncompromising code formatter.
Author: Łukasz Langa
License: MIT
Location: /Users/kevin/pip_show_broken/lib/python3.7/site-packages
Requires: appdirs, click, toml, attrs

This comment has been minimized.

Copy link

@xavfernandez xavfernandez commented Aug 30, 2019

Thanks for the report, I can reproduce the issue.

The fix should be quite simple:

name = dist.get('name', '')
required_by = [
pkg.project_name for pkg in pkg_resources.working_set
if name in [ for required in pkg.requires()]

We are comparing the project names without normalisation and Click would require it since it uses a capital C.

>>> [pkg for pkg in pkg_resources.working_set if pkg.project_name == 'Click'][0].project_name
>>> [pkg for pkg in pkg_resources.working_set if pkg.project_name == 'black'][0].requires()
[Requirement.parse('click>=6.5'), Requirement.parse('attrs>=18.1.0'), Requirement.parse('appdirs'), Requirement.parse('toml>=0.9.4')]

For the contributors interested in fixing it, canonicalize_name would be the function to use.

@pfmoore pfmoore closed this in #6957 Sep 4, 2019
@lock lock bot added the S: auto-locked label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
2 participants
You can’t perform that action at this time.