我不确定这是可能的.谷歌似乎没有任何答案.
运行Linux Debian可以列出安装的所有pip包和大小(使用的磁盘空间量)吗?
即列出pip
磁盘大小的所有包?
请试试这个(虽然有点长,也许有更好的解决方案):
$ 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
输出应如下所示:
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 ...
如果安装包,应该工作Location/Name
.(位置和名称来自pip show
)
pip show
会告诉你的位置:
--- 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: armin.ronacher@active-4.com License: BSD Location: /home/lord63/.pyenv/versions/2.7.11/envs/py2/lib/python2.7/site-packages Requires: itsdangerous, Werkzeug, Jinja2
我们得到Name
并Location
加入他们获取位置,最后用于du -sh
获取包大小.
新版本的新点子列表格式:
pip2 list --format freeze|awk -F = {'print $1'}| xargs pip2 show | grep -E 'Location:|Name:' | cut -d ' ' -f 2 | paste -d ' ' - - | awk '{print $2 "/" tolower($1)}' | xargs du -sh 2> /dev/null|sort -h