Does uninstalling a package with “pip” also remove

2019-01-10 12:11发布

When you use pip to install a package, all the required packages will also be installed with it (dependencies). Does uninstalling that package also remove the dependent packages?

4条回答
老娘就宠你
2楼-- · 2019-01-10 12:21

No, it doesn't uninstall the dependencies packages:

$ pip install specloud
$ pip freeze

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3
specloud==0.4.5

$ pip uninstall specloud
$ pip freeze

figleaf==0.6.1
nose==1.1.2
pinocchio==0.3

As you can see all the packages are still there but not the specloud package itself.

查看更多
放我归山
3楼-- · 2019-01-10 12:30

You can install and use the pip-autoremove utility to remove a package plus unused dependencies.

# install pip-autoremove
pip install pip-autoremove
# remove "somepackage" plus its dependencies:
pip-autoremove somepackage -y
查看更多
仙女界的扛把子
4楼-- · 2019-01-10 12:41

You may have a try for https://github.com/cls1991/pef. It will remove package with its all dependencies.

查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-10 12:43

i've successfully removed dependencies of a package using this bash line:

for dep in $(pip show somepackage | grep Requires | sed 's/Requires: //g; s/,//g') ; do pip uninstall -y $dep ; done

this worked on pip 1.5.4

查看更多
登录 后发表回答