Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to completely uninstall python 2.7.13 on Ubuntu 16.04

I installed Python 2.7.13 on Ubuntu 16.04 according to this guide, and it became the default version as an alternative to the version 2.7.12. But, I wanted to completely remove Python 2.7.13 and return back to the version 2.7.12 as the default version since the pip command does not work with the following error.

bash: /usr/local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory

Could you please help me how to completely remove Python 2.7.13 from Ubuntu 16.04? Otherwise, could you please suggest how to fix the above error?

like image 605
Lucas Avatar asked Jun 17 '17 07:06

Lucas


People also ask

How do I completely remove python2 from Ubuntu?

If you are satisfied with the result(outcome) then you may do actual remove by: sudo apt remove python2 and then sudo apt autoremove --purge to remove the configuration files and the unused packages. Hope it helps you.

How do I remove old versions of Python from Ubuntu?

Navigate to Control Panel. Click “Uninstall a program”, and a list of all the currently installed programs will display. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.

How do I uninstall Python 2.7 from command prompt?

In the Command line, open the directory where the Python is installed, and then utilize the “del python.exe” command to remove Python from the system.


3 Answers

How I do:

# Remove python2
sudo apt purge -y python2.7-minimal

# You already have Python3 but 
# don't care about the version 
sudo ln -s /usr/bin/python3 /usr/bin/python

# Same for pip
sudo apt install -y python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip

# Confirm the new version of Python: 3
python --version
like image 85
Benoit Mariaux Avatar answered Oct 22 '22 03:10

Benoit Mariaux


caution : It is not recommended to remove the default Python from Ubuntu, it may cause GDM(Graphical Display Manager, that provide graphical login capabilities) failed.

To completely uninstall Python2.x.x and everything depends on it. use this command:

sudo apt purge python2.x-minimal

As there are still a lot of packages that depend on Python2.x.x. So you should have a close look at the packages that apt wants to remove before you let it proceed.

Thanks, I hope it will be helpful for you.

like image 82
Subarata Talukder Avatar answered Oct 22 '22 03:10

Subarata Talukder


try following to see all instances of python

whereis python
which python

Then remove all instances using:

sudo apt autoremove python

repeat sudo apt autoremove python(for all versions) that should do it, then install Anaconda and manage Pythons however you like if you need to reinstall it.

like image 34
Sean Avatar answered Oct 22 '22 02:10

Sean