pip-autoremove

pip-autoremove

https://pypi.org/project/pip-autoremove/

Remove a package and its unused dependencies. (删除软件包及其未使用的依赖项。)

1. Quickstart

First, install pip-autoremove:

$ pip install pip-autoremove

Install a package which has dependencies, e.g. Flask: (安装具有依赖项的软件包,e.g. Flask)

$ pip install Flask

...
Successfully installed Flask Werkzeug Jinja2 itsdangerous markupsafe
Cleaning up...

Uninstall it and all its unused dependencies: (卸载它及其所有未使用的依赖项:)

$ pip-autoremove Flask -y

Flask 0.10.1 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Werkzeug 0.9.6 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Jinja2 2.7.3 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
        MarkupSafe 0.23 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    itsdangerous 0.24 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)

Uninstalling MarkupSafe:
  Successfully uninstalled MarkupSafe
Uninstalling Jinja2:
  Successfully uninstalled Jinja2
Uninstalling itsdangerous:
  Successfully uninstalled itsdangerous
Uninstalling Werkzeug:
  Successfully uninstalled Werkzeug
Uninstalling Flask:
  Successfully uninstalled Flask

Remove multiple packages and their dependencies at once: (一次删除多个软件包及其依赖项:)

$ pip install Flask Sphinx

...
Successfully installed Flask Sphinx Werkzeug Jinja2 itsdangerous Pygments docutils markupsafe
Cleaning up...
$ pip-autoremove Flask Sphinx -y

Sphinx 1.2.2 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Jinja2 2.7.3 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
        MarkupSafe 0.23 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Pygments 1.6 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    docutils 0.12 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
Flask 0.10.1 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Werkzeug 0.9.6 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    Jinja2 2.7.3 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
        MarkupSafe 0.23 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
    itsdangerous 0.24 (/tmp/pip-autoremove/.venv/lib/python2.7/site-packages)
...

2. Usage

Usage: pip-autoremove [OPTION]... [NAME]...

Options:
  --version     show program's version number and exit
  -h, --help    show this help message and exit
  -l, --list    list unused dependencies, but don't uninstall them.
  -L, --leaves  list leaves (packages which are not used by any others).
  -y, --yes     don't ask for confirmation of uninstall deletions.
yongqiang@deepnorth-amax:~$ pip-autoremove --version
pip-autoremove 0.9.1
yongqiang@deepnorth-amax:~$
yongqiang@deepnorth-amax:~$ pip-autoremove -l
Traceback (most recent call last):
  File "/usr/local/bin/pip-autoremove", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 104, in main
    list_dead(args)
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 29, in list_dead
    graph = get_graph()
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 89, in get_graph
    for req in requires(dist):
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 95, in requires
    return map(get_distribution, dist.requires())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 535, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 415, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 695, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (numpy 1.11.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('numpy>=1.11.1'))
yongqiang@deepnorth-amax:~$
yongqiang@deepnorth-amax:~$ pip-autoremove -L
Traceback (most recent call last):
  File "/usr/local/bin/pip-autoremove", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 102, in main
    list_leaves()
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 118, in list_leaves
    graph = get_graph()
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 89, in get_graph
    for req in requires(dist):
  File "/usr/local/lib/python2.7/dist-packages/pip_autoremove.py", line 95, in requires
    return map(get_distribution, dist.requires())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 535, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 415, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 695, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (numpy 1.11.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('numpy>=1.11.1'))
yongqiang@deepnorth-amax:~$

3. sudo pip install pip-autoremove

yongqiang@deepnorth-amax:~$ sudo pip install pip-autoremove
[sudo] password for yongqiang:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/yongqiang/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip-autoremove
  Downloading https://files.pythonhosted.org/packages/0a/1d/f9ba8d36c6d24726b8615d53522bf237db0a78f39d14eafa242f032d9a1e/pip_autoremove-0.9.1-py2.py3-none-any.whl
Installing collected packages: pip-autoremove
Successfully installed pip-autoremove-0.9.1
WARNING: You are using pip version 19.3; however, version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
yongqiang@deepnorth-amax:~$
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值