Created
January 10, 2018 20:36
-
-
Save orendon/292a2f3abbb7fa85197f62677de7428e to your computer and use it in GitHub Desktop.
Python: list pip packages size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip list | xargs pip show | grep -E 'Location|Name' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It'd probably be safer to use one of the other list formats which are intended to be machine-parseable:
or
Personally, I'd just do this as the entire solution, if I was on a system with GNU awk (so a Mac user or Solaris or whatever might need to use gawk instead of awk; I forget if
tolower
is standard awk or a GNU extension):That gives this output on a python 3.9 container with pygments installed. It still fails for some eggs, but gets you close.