I have read many answers regarding this kind of problem but unfortunately, I am unable to achieve the uninstallation. So please don't downvote or flag this question.

I have python2.7.8 installed in ~/Downloads/Python2.7.8 directory using setup.py. I had a system-wide installation of python as well(some other version). To uninstall the 2.7.8 version, I issued the command sudo apt-get remove python which removed rhythmbox, totem etc. alongwith my systemwide python installation.

Now, when I issue the command which python, the output is /usr/local/bin/python.

The output of python --version is Python 2.7.8.

I am using Ubuntu 14.04

Please help me uninstall Python 2.7.8. Thanks in advance!!

  • 1
    "I have read many answers regarding this kind of problem but unfortunately, I am unable to achieve the uninstallation." Welcome to superuser. Could you please list the methods that you have already tried to solve this problem? – user391035 Nov 20 '14 at 18:13
  • And also give the output of: ls -l /usr/bin/python /usr/local/bin/python and /usr/bin/python --version – user391035 Nov 20 '14 at 18:20
  • @user391035: I did sudo pip uninstall python from ~/Downloads/Python-2.7.8 directory. It dislpalyed Uninstalling python: /usr/local/lib/python2.7/lib-dynload/Python-2.7.8-py2.7.egg-info. Then displayed "Successfully uninstalled python". But python --version and which python still give the same output. – crisron Nov 20 '14 at 18:22
  • @user391035: The outputs you asked for are respectively: lrwxrwxrwx 1 root root 9 Dec 21 2013 /usr/bin/python -> python2.7 and lrwxrwxrwx 1 root root 7 Nov 20 21:16 /usr/local/bin/python -> python2 – crisron Nov 20 '14 at 18:26
  • @user391035: I also tried sudo easy_install pip, then pip freeze. It gives output as wsgiref==0.1.2. Then I did pip uninstall wsgiref but it gives error. Also, when I run python setup.py develop from ~/Downloads/Python2.7.8 directory, it gives error. – crisron Nov 20 '14 at 18:34

You can not use apt-get to uninstall python since you did not use it or any pre-built package to install python. It just simply doesn't know about this installation so it can not undo the installation.

Initial solution: (It came out later in the comments that the user has already tried to do this.)

There is a popular post about this on [StackOverflow]:https://stackoverflow.com/questions/1550226/python-setup-py-uninstall.

Copied from the site:

You need to remove all files manually, and also undo any other stuff that installation did manually.

If you don't know the list of all files, you can reinstall it with the --record option, and take a look at the list this produces.

To record list of installed files, you can use:

python setup.py install --record files.txt

Once you want to uninstall you can use xargs to do the removal:

cat files.txt | xargs rm -rf

Second solution:

The reason why you are getting the python from /usr/local/bin/ and not from /usr/bin/ is that the first folder comes before the second in your $PATH variable. So the system finds the manually installed version of python first. We can clean this part of the system easily.

If you are sure that there should only be the original python installed on your system then do the following:

cd /usr/local/bin/
sudo rm python python-config python2 python2-config python2.7 python2.7-config

Side note: The general idea of not using * here is to avoid people accidentally deleting files from their main python installation.

Since you have run several uninstallation methods it would be tricky to be a 100% sure that you managed to remove everything but this way you would be be able to use the default python.

  • I did this. It still doesn't uninstall python. – crisron Nov 20 '14 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.