-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add flag to automatically remove unused dependencies, like pip-autoremove #9118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that in order to do this correctly, pip will need to have a database of which packages are automatically installed as dependencies. E.g. A depends on B and one initially needed A and B, then perse only needs B, so pip purge A shouldn't remove B. |
That would be a nice feature but it's unnecessary. |
I'd argue that not randomly breaking one's environment is much more than just a nice feature.
Because it's explicit. Whilst
is technically true, it's implicit, dangerous and unexpected (not how any package manager providing similar functionality does it). It might suit trying and removing programs/libraries in a working session (which can be done in virtual environments), yet for long-term management of end-user environments (as in where people install youtube-dl, thefuck, ect. and libraries for their local scripts), it's just asking for trouble. I'm sure that there are many ways to track manual install, but as an user I insist that it must be done. |
I understand the feature can be nice for some, but pip maintainers take the blunt when some of the users find the feature to not fit their expectation. So new feature requests need to be thought through quite extensively before they can even be considered for acceptance. Tracking manual package installation is a hard problem (which may be unexepected), and most package managers resort to doing this the other way around, requiring the user to specify what are needed and purge the rest, which may be a better solution. |
The same rational has been spelled out in #2635. Although pip does have a proper resolver now, it is still lacking information required to do this properly, and may continue to lack them forever (since some of the features are arguably out of scope). I would recommend you looking into alternative project management tools instead, as mentioned in the linked issue. |
Marking as a duplicate to #5823. |
What's the problem this feature will solve?
Remove a package and its unused dependencies. Pip cannot do this.
Describe the solution you'd like
Automatically remove no-longer-used dependencies when uninstalling a package, via a flag like
-r
or--autoremove
.This would help declutter installations when removing packages with many dependencies, like jupyter-lab or tensorflow.
And it's easy to implement. pip-autoremove does it in <100 loc.
Alternative Solutions
The alternative is manually removing packages, or nuking the installation, which is not always possible.
Additional context
Example, an old jupyter-lab install's dependencies:
Enjoy pruning that by hand without breaking any other packages.
The text was updated successfully, but these errors were encountered: