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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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
回答3:
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
回答4:
You may have a try for https://github.com/cls1991/pef. It will remove package with its all dependencies.