How to uninstall python in ubuntu completely and reinstalling it?

My python was corrupted due to some module. So I planned to re-installed or remove the python completely from my Ubuntu 16.04 machine. But sudo apt-get install --reinstall python2.7 command was also failing and was throwing same error. So I finally Did few hacks and cracks. Here are the steps -Removing all python version manually

 - sudo rm -rf /usr/bin/python2.x as well as python3.x
 - sudo rm -rf /usr/lib/python2.x as well as python3.x
 - sudo rm -rf /usr/local/lib/python2.x as well as python 3.x  

Updating Ubuntu

 - sudo apt-get update

In Between if you get this error The package needs to be reinstalled ubuntu Then Run following command

sudo vi /var/lib/dpkg/status 

And delete all the lines from above file for the package which was expecting re-install and run sudo apt-get update again.

Now download a python tgz file from https://www.python.org/downloads/ and unzip it and CD into it

./configure
make test
sudo make install

Python should be installed now. Check by running python

Leave a Comment

tech