how to uninstall pip packages code example

Example 1: pip3 uninstall all

pip3 freeze | xargs pip3 uninstall -y

Example 2: delete all pip packages

#Write all modules to a txt file
pip freeze > requirements.txt

#Now to remove one by one:
pip uninstall -r requirements.txt

#If we want to remove all at once then:
pip uninstall -r requirements.txt -y

Example 3: pip remove

# python2
pip uninstall package_name
# python3
pip3 uninstall package_name

Example 4: uninstall package with pip

##in console write: pip uninstall <packagename>
pip uninstall <packagename>

Example 5: pip remove package

pip uninstall <package_name>

Example 6: pip uninstalled itself

#the best way to install pip if uninstalled is using the following command

python -m ensurepip

# not only it will check whether there is pip installed , it will install 
# for you if not found