pip-autoremove
pip-autoremove is a command-line utility that extends pip's functionality to automatically remove a specified package along with any of its dependencies that are no longer required by other installed packages. It helps keep your Python environments clean and lean. The current version is 0.10.0, and it appears to be actively maintained with recent updates.
Common errors
-
ERROR: unknown command "autoremove"
cause The pip-autoremove package is either not installed or pip's internal command cache hasn't been refreshed, preventing the 'autoremove' subcommand from being recognized.fixFirst, ensure `pip install pip-autoremove` was successful. If installed, try closing and reopening your terminal or command prompt to refresh the shell's environment and pip's entry points. -
TypeError: 'NoneType' object is not subscriptable
cause This error, or similar `AttributeError` related to `pip._internal` modules, usually indicates an incompatibility between your installed version of `pip-autoremove` and the current version of `pip`.fixThis is a common issue due to `pip`'s unstable internal APIs. Check `pip-autoremove`'s GitHub for updates or compatibility warnings. You might need to upgrade `pip-autoremove` or temporarily downgrade `pip` (e.g., `pip install pip==21.3.1`) to a version known to be compatible. -
WARNING: Skipping <package_name> as it is not installed.
cause The package you specified for removal is not found in the currently active Python environment.fixVerify the package name for typos. Ensure you are in the correct virtual environment where the package was originally installed, then retry the command.
Warnings
- breaking pip-autoremove relies on pip's internal APIs, which are not stable and can change significantly between pip versions. This frequently leads to pip-autoremove breaking after pip updates.
- gotcha Always review the list of packages pip-autoremove proposes to remove. It might suggest removing packages that are explicitly installed but also happen to be a dependency of another package, or packages you wish to keep for other reasons.
- gotcha The `--no-confirm` or `-y` flag bypasses all interactive confirmation prompts. Using it carelessly can lead to unintended and irreversible package removals.
Install
-
pip install pip-autoremove
Imports
- pip-autoremove is a CLI tool.
This library is primarily a command-line interface tool and is not designed for direct programmatic import or use within Python scripts. Its functionality is exposed via the `pip autoremove` command.
Quickstart
pip install pip-autoremove pip autoremove <package_name_to_remove>