I am relatively new to this. I have installed various python2.7 packages, sometimes with apt-get, sometimes with pip, sometimes from source. I am experiencing millions of different issues when trying to remove, upgrade or install a new package. So, I want to remove ALL python packages, and start with a clean installation. Is there a relatively safe way to do this?
This is an answer to your question!
pip has an option that allows you to process an uninstall without confirmation:
--yes. So if you get all packages and then execute them one by one with the uninstaller, you'll remove all of them.
To do that you can use the
xargs command: it will allow you to use
\n as a separator (see man xargs for more information)
so all that together is just one command that will remove all of the installed Python packages::
pip freeze | xargs pip uninstall --yes