Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see pip package sizes installed?

I'm not sure this is possible. Google does not seem to have any answers.

Running Linux Debian can I list all pip packages and size (amount of disk space used) thats installed?

i.e. List all pip packages with size on disk?

like image 827
Prometheus Avatar asked Dec 14 '15 11:12

Prometheus


People also ask

How do I determine the size of my pip package?

pip3 show numpy | grep "Location:" this will return path/to/all/packages. du -h path/to/all/packages. last line will contain size of all packages in MB.

How do I check Python pip package?

If you want to list all the Python packages installed in an environment, pip list command is what you are looking for. The command will return all the packages installed, along with their specific version and location. If a package is installed from a remote host (for example PyPI or Nexus) the location will be empty.

How do I check the size of a Python module?

Use the getsizeof() Function in the sys Module to Get the Object Size in Python. The getsizeof() function provided by the sys module is the most commonly used function to get the size of a particular object in Python.

How much space do Python packages take?

Python packages can require many gigabytes of storage. By default they are installed in your /home directory which is typically around 10-50 GB. Be sure to run the checkquota command before installing to make sure that you have space.


1 Answers

Could please try this one(A bit long though, maybe there are better solutions):

$ 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 

the output should look like this:

80K     /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/blinker 3.8M    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/docutils 296K    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/ecdsa 340K    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/execnet 564K    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/fabric 1.4M    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/flask 316K    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/httplib2 1.9M    /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages/jinja2 ... 

should works if the package is installed in Location/Name. (location and name are from pip show <package>)


pip show <package> will show you the location:

--- Metadata-Version: 2.0 Name: Flask Version: 0.10.1 Summary: A microframework based on Werkzeug, Jinja2 and good intentions Home-page: http://github.com/mitsuhiko/flask/ Author: Armin Ronacher Author-email: [email protected] License: BSD Location: /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages Requires: itsdangerous, Werkzeug, Jinja2 

we get the Name and Location to join them to get the location, finally use du -sh to get the package size.

like image 111
lord63. j Avatar answered Sep 23 '22 13:09

lord63. j