How Do I Remove All Packages Installed via Pip in My Virtual Environment?

Patricia Arquette
Release: 2024-11-02 06:36:29
Original
410 people have browsed it

How Do I Remove All Packages Installed via Pip in My Virtual Environment?

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
Copy after login

Step 2: Uninstall them one by one using:

pip uninstall <package_name>
Copy after login

Method 2: One-Command Removal

If you prefer a more efficient approach, use the following command:

pip freeze | xargs pip uninstall -y
Copy after login

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
Copy after login

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>
Copy after login

To remove them, first extract the package name using:

pip freeze | cut -d "@" -f1
Copy after login

Then uninstall them with:

xargs pip uninstall -y
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!