55

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.

4 Answers 4

33

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Can you elaborate on the dpkg -r command? I am in the Python source directory and when I run that command it doesn't work. It also says the deb file isn't install even after I run dpkg -i with the deb file.
Didn't work for me either. It says I need to use dpkg -r python to uninstall, which attempts to uninstall python completely!
Be especially careful, when you create .deb of your installation (step 2 in answer) - check the name of created package. In my case I tried to remove python 3.6.3 package. By default checkinstall created deb with name python. I ran dpkg -r, but it said, that package was not installed, I tried sequence of dpkg -i dpkg -r. That sequence overwrite contents of /var/lib/dpgk/status and now I got python of version of 3.6.3 and lots of python 2.* dependencies were reported broken by apt-get check. I had to change contents of dpkg status file manually to recover.
I find with python 3.6.9 this works but dpkg or apt doesn't clean-up all the site packages - because of the way ensurepip is called from the python makefile. It still does 90% of the work for you, but I find I have to manually purge the correct site-packages folder for any reinstallation to reinstall pip.
7

I did the following and reinstall using 'make install' and it worked.

whereis python3.6
rm -rf /usr/local/lib/python3.6
rm -rf /usr/local/bin/python3.6*
make install

Comments

0

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/

2 Comments

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.
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 uninstall Here are a few links that may be useful: serverfault.com/questions/50323/… linuxforums.org/forum/redhat-fedora-linux-help/…
0

In the future it may be prudent to use sudo checkinstall.

3 Comments

Why? What is it? A little bit more info would be helpful.
This seems to be a minimal version of @unutbu's answer, which did not yet exist at the time. It was perhaps marginally useful at the time, but I am now downvoting this as redundant and obscure.
Not readily available on all platforms, unfortunately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.