python - 如何查看安装的 pip 包大小?

标签 python linux debian pip

我不确定这是否可行。 Google 似乎没有任何答案。

运行 Linux Debian 我可以列出所有安装的 pip 包和大小(使用的磁盘空间量)吗?

即列出磁盘上所有的 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 <package>)


pip show <package>会告诉你位置:

---
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

我们得到 NameLocation加入他们以获得位置,最后使用 du -sh获取包大小。

关于python - 如何查看安装的 pip 包大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34266159/

相关文章:

python - 向 Telegram 发送图像时出现 'Request Entity Too Large' 错误是什么原因?

从 SIGINT 句柄调用一个复杂的函数 - 什么时候可以?

Debian 软件包 : where is the right place to put temporary installation files?

linux - Gitlab 在端口 8080 上

ubuntu - 使用 dpkg 为 systemd 和 upstart 配置打包

python - 在 QML 中显示 pandas 数据框

python - scrapy 与负载请求

python - 字符串不会写入文件

linux - 如何在 Linux 中更改窗口位置时得到通知?

mysql - 从 shell 脚本将表导出为 mysql 中的 csv