How to see pip package sizes installed?

· 333 words · 2 minute read

Use this command to see installed pip packages sorted by their descending order of sizes.

pip list | tail -n +3 | awk '{print $1}' | xargs pip show | grep -E 'Location:|Name:' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null | sort -hr

If your installed pip is pip3 or pip3.7 or pip3.8 or pip3.9 or pip3.10, just replace pip with the package you installed in the two occurences in the command. For example, if your installed Python package manager is pip3.7, use this command.

pip3.7 list | tail -n +3 | awk '{print $1}' | xargs pip3.7 show | grep -E 'Location:|Name:' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null | sort -hr

list all pip installed packages sorted by size

If the above commands does not work properly on your operating system, use this command instead.

pip3 list --format freeze|awk -F = {'print $1'}| xargs pip3 show | grep -E 'Location:|Name:' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null|sort -h

list all pip installed packages sorted by size

make sure to specify the pip version you installed on your system.

Another command you can use to list all installed packages by pip.

du -h -d 1 "$(pip -V | cut -d ' ' -f 4 | sed 's/pip//g')" | grep -vE "dist-info|_distutils_hack|__pycache__" | sort -h

list all packages installed by pip

note: if your operating system is Mac OS, use pip3 or pip3.7 or pip3.8 or pip3.9 pr pip3.10 or maybe all of them installed.

note: if your operating system is Linux such as Ubuntu, Debian, Arch, Linux Mint, Elementary OS, Manjaro, .. or any other Linux distribution, use pip because linux makes an alias for the any Python package manager installed to be just pip. But make sure you don’t have another pip with different version installed.

Share:
waffarx cash back