Home > Article > Backend Development > How can I uninstall all pip-installed packages in a virtual environment?
Uninstalling Pip-Installed Packages in Virtual Environments
If you're working with a virtual environment and want to remove all packages installed via pip, there are several approaches you can take.
Method 1: Using Pip Freeze with Xargs
This method involves using Pip Freeze to generate a list of installed packages, and then using Xargs to pass this list to Pip Uninstall for bulk uninstallation.
pip freeze | xargs pip uninstall -y
Method 2: Excluding Editable Packages
If you have packages installed via version control systems (VCS), you can exclude them from the list before uninstallation.
pip freeze --exclude-editable | xargs pip uninstall -y
Method 3: Handling Direct GitHub/GitLab Installations
Packages installed directly from GitHub or GitLab may have "@
pip freeze | cut -d "@" -f1 | xargs pip uninstall -y
The above is the detailed content of How can I uninstall all pip-installed packages in a virtual environment?. For more information, please follow other related articles on the PHP Chinese website!