Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall python in ubuntu completely and reinstalling it?

The default python version was 2.7.12 in ubuntu. I installed python2.7.13 using the below commands.

Then download using the following command:

version=2.7.13
cd ~/Downloads/
wget https://www.python.org/ftp/python/$version/Python-$version.tgz

Extract and go to the directory:

tar -xvf Python-$version.tgz
cd Python-$version

Now, install using the command you just tried, using checkinstall instead to make it easier to uninstall if needed:

./configure
sudo make install

Now there is some issue in pandas(giving no module named pandas when I try to import but if we try to install it shows required already satisfied) so I want to completely remove python 2.7.13 and reinstall python 2.7.12. How can I achieve this?

like image 365
Prajna Hegde Avatar asked Feb 21 '18 06:02

Prajna Hegde


People also ask

How do I completely remove Python from Linux?

Find and click the “Environment Variables” button. Highlight the “Path” variable in the system variable section by left-clicking it. Then press the “Edit” button. If you see a path of the Python bin folder in the menu, remove it by selecting it and pressing the “Delete” button on the right side of the menu.


1 Answers

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

like image 86
Shailendra2014 Avatar answered Sep 25 '22 17:09

Shailendra2014