views:

60

answers:

5

I've installed python 2.6 from source, and somehow later mistakenly installed another python 2.6 from a package manager too.

I can't find a way to uninstall a python that was built from source, is this possible/easy?

Running ubuntu 10.04

Thanks.

A: 

Have you looked into make uninstall I believe this should work for you, assuming you have the python 2.6 source and the make file has uninstall available (it should).

http://www.linuxquestions.org/questions/linux-newbie-8/source-uninstall-with-make-uninstall-howto-230225/

Louis
Running ./configure then `make uninstall' returns `make: *** No rule to make target `uninstall'. Stop.'. Maybe i downloaded the wrong python version? Edit: tried it with the correct version, same result.
Ian P
Sounds like the make file doesn't have any reference for uninstall. It's possible that your python installation created a setup.py file, in which case you can do a: setup.py uninstallHere are a few links that may be useful:http://serverfault.com/questions/50323/uninstall-python-packages-built-from-sourcehttp://www.linuxforums.org/forum/redhat-fedora-linux-help/138085-how-uninstall-python.html
Louis
A: 

Do you still have the source directory where you compiled Python before? If so, you can CD into that directory and run sudo make uninstall.

If you don't have it still, you could re-create it by going through the build steps again--download, extract, configure, and make--but end with sudo make uninstall instead of sudo make install, of course.

ewall
+1  A: 

In the future it may be prudent to use sudo checkinstall

Maletor
+3  A: 

You can use checkinstall to remove Python. The idea is:

  1. Install checkinstall
  2. Use checkinstall to make a deb of your Python installation
  3. Use dpkg -r to remove the deb.

See this post for more details.

PS. Note that Ubuntu must always have at least one installation of Python installed, or else major pieces of your OS stop working. Above, I'm assuming it's safe to remove the Python built from source, without removing the Python that was installed by the package manager.

PPS. If you accidentally erase all Python installations from your Ubuntu machine, all is not lost. Instructions on how to recover from this situation can be found here.

unutbu
This appears to have worked, thanks!
Ian P
@Ian: Great. Glad it worked out for you.
unutbu
+1  A: 
  1. "make uninstall" is your best bet. Unfortunately, it sounds like your particular source install doesn't have an "uninsall" target. Drag :(

  2. "setup.py uninstall" is another good suggestion. Please post back if you have it, and if it worked. Unfortunately, it, too, might not exist with your particular source install.

  3. Failing all else, a "brute force" method would be:

    a) dpkg -l # Find out the exact version of your Python package

    dpkg -L YOUR_PYTHON_PACKAGE_AND_VERSION # Get a list of all files in the package

    b) cd YOUR_PYTHON_SOURCE

    ./configure

    make clean

    make install # Get a list of all files in the source install

    c) dpkg -r YOUR_PYTHON_PACKAGE_AND_VERSION # Remove the package

    d) Go on a search-and-destroy mission for all files you identified in steps a) and b)

    e) Reinstall from package (recommended) or source

    f) Voila! Done.

'Hope that helps .. PSM