How to remove all packages installed by pip

How to remove all packages installed by pip

Sometimes you want to get rid of all python packages. There is a quick and easy way to do this. The command below will also remove the packages installed via VCS.

pip freeze | grep -v "^-e" | xargs pip uninstall -y

You may also use the command below. The command will also remake virtualenv which includes the python executable, base libraries, etc.

virtualenv --clear __Your_Env_Name__

You should always back up the pip list before clearing all packages.

References

  1. https://pip.pypa.io/en/stable/cli/

  2. https://virtualenv.pypa.io/en/latest/cli_interface.html#section-creator