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?
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.
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.
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.
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With