How to install Python on Debian GNU/Linux (Python-2.7.2.tar.bz2)

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Dec 5 11:23:21 EST 2011


On Tue, 06 Dec 2011 02:51:21 +1100, Chris Angelico wrote:

> On Tue, Dec 6, 2011 at 2:40 AM, patrickwayodi <patrickwayodi at gmail.com>
> wrote:
>>> You should actually already have Python installed. Try typing 'python'
>>> at a terminal and see if it invokes the interactive interpreter.
>>>
>>> ChrisA
>>
>>
>> Yes, I have Python installed, but it's an old version. So I want to
>> upgrade to "Python-2.7.2.tar.bz2".
> 
> Ah gotcha. I believe you can 'sudo apt-get install python2.7' - at
> least, you can on the Ubuntu system next to me. Not sure though; I build
> my Python from source straight from Mercurial.
> 
> What you have there, I think, is a source code snapshot. You'd need to
> extract it and then do the usual incantation: $ ./configure
> $ make
> $ sudo make install

And you have now potentially broken your system python :(

Generally speaking, unless you are an expert, you should not use make 
install when installing Python from source, because it will replace the 
system Python with the newly installed one.

Instead use `sudo make altinstall`. This is exactly the same as install, 
except it won't replace the python symlink that points to the actual 
Python executable. That way system tools that call Python get the version 
they are expecting, together with any libraries installed for their use, 
while you can call the version you prefer manually. Or set up an alias in 
your bashrc file.


> If you don't have the compiler/build environment set up, you'll have to
> do that first.

The trickiest part for me is ensuring that tkinter works correctly. After 
installing Python from source about a dozen times now, I still don't know 
why sometimes it works and sometimes it doesn't.


-- 
Steven



More information about the Python-list mailing list