Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstalling packages with dependencies with pip [duplicate]

Is there a way to uninstall a package and all their dependencies through pip rather than uninstalling each dependency from my venv one by one? Or erasing my entire pip installs and then reinstalling the packages and dependencies that I want?

like image 871
Donnahue George Avatar asked Sep 19 '25 21:09

Donnahue George


2 Answers

you may use pip-autoremove

this tool can remove package and its dependencies.

like image 62
jxyu Avatar answered Sep 22 '25 10:09

jxyu


Is there a way to uninstall a package and all their dependencies through pip rather than uninstalling each dependency from my venv one by one?

I use this bash function

pipdepuninstall () 
{ 
    pip install -q pipdeptree
    pipdeptree -p$1 -fj | jq ".[] | .package.key" | xargs pip uninstall -y
}

This removes all dependencies of a package, and the package itself.

$ pip install Flask
$ pipdepuninstall Flask
like image 41
miraculixx Avatar answered Sep 22 '25 10:09

miraculixx