Uninstalling Packages Installed via Pip
To remove all packages installed using pip within your active virtual environment, consider the following methods:
Method 1: Standard Approach
Step 1: Retrieve a list of installed packages using:
pip freeze
Step 2: Uninstall them one by one using:
pip uninstall <package_name>
Method 2: One-Command Removal
If you prefer a more efficient approach, use the following command:
pip freeze | xargs pip uninstall -y
Additional Considerations:
Excluding VCS Packages:
If packages are installed through version control systems (VCS), exclude them with:
pip freeze --exclude-editable | xargs pip uninstall -y
Handling Packages Installed from Git/GitLab:
Packages installed directly from these platforms will have the syntax "@. For example:
django @ git+https://github.com/django.git@<sha>
To remove them, first extract the package name using:
pip freeze | cut -d "@" -f1
Then uninstall them with:
xargs pip uninstall -y
The above is the detailed content of How Do I Remove All Packages Installed via Pip in My Virtual Environment?. For more information, please follow other related articles on the PHP Chinese website!