Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a python package previously installed via apt(by default). Now I want to install new version and compile it manually from the sources with all the required modules.

How can I do that? I suppose that

apt-get purge python

And then install from sources is not possible because python have lots of dependencies and will uninstall all of them in this case.

What is the right way to do that?

share|improve this question

You'll want to look at the command sudo apt-get build-dep python which will install all the build dependencies, but not the package itself.

share|improve this answer
I could be wrong but doesn't this install the build dependencies and not neccessarily the runtime dependencies? I mean, you would want this to build python but would it satisfy all the required packages of a python binary? – Oli Nov 17 '10 at 0:46
To be honest, I haven't tried it with python, but I haven't had problems in the past. At the very least, it'll save a heap of searching and compiling :) – Jeremy Nov 17 '10 at 0:52
this is a good approach, you still have to troubleshoot additional module stuff. my experience was with ruby/ffmpeg/mplayer/other. not all modules are considered critical in the base they don't get pulled in with build-dep, but it's a faster start – RobotHumans Nov 17 '10 at 2:45

From your question I may not have understood what you are up to do. Please forgive me if I was wrong. In any case you don't want to purge python as much of Ubuntu depends on it.

To install an updated application (written in python) from source you most likely don't need to compile it as it can be run in the python interpreter provided with Ubuntu. When it comes to dependencies you may have to install them manually: check with the documentation that comes with your application.

In case the program update includes a DEB file you can perform the update conveniently with your preferred package manager.

share|improve this answer

No, you don't really need to purge your python installation, you just have to make the Ubuntu default version and the source compiled version live together peacefully.

To achieve that just compile the source in your home folder or, if you want to install for all users, user another installation prefix ( e.g. /usr/local/ instead of /usr/ )

Obviously only one python should be set in the system PATH ( and that should be the default one ).

Then to run a python script with the new version ( useful if you want to use python 3.0 while Ubuntu has 2.x installed ) just type:


also you can create a symlink of the new python to /usr/bin and call it /usr/bin/python30.

Hope this helps :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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