Monday, January 3, 2022

[SOLVED] How do I completely clean-up or reset a Python installation on Ubuntu

Issue

Package management and juggling pip, anaconda, PPAs, and virtual-environments is difficult. Somewhere in my constellation of dependencies, things are broken. I'm on Ubuntu 18.04. As far as I know, I cannot fix these dependencies by hand.

The problem, for what it's worth: I've been unable to use tensorflow for a few months. Every time I try to fix it, even uninstalling and reinstalling everything to the best of my knowledge, things still don't work. After sinking enough hours, I'm looking for a "nuclear solution".

What I would like to do is cleanly remove everything except Python and any Python packages my system might require, so that I can start fresh (and hopefully do things properly.)

So, my question: How can I systematically clean up or remove my Python installation? I want to wipe everything and start anew. Does there exist a systematic guide, or a smart and reputable script that does this?


Solution

You can try sudo apt purge python-pip python-dev, or python3 and python3-pip if you're using Python 3. This must remove all files/folders created by the installed packages. But I'm not really sure you need to do it.

The better solution is just to uninstall all pip packages, like pip freeze | xargs pip uninstall -y. Just to be sure you can even remove pip folder /usr/lib/python2.7/site-packages manually (or similar folder for Python 3).



Answered By - sortas