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

P

patrickwayodi

Hi,
How can I install Python on Debian GNU/Linux? I downloaded the file
"Python-2.7.2.tar.bz2" but I don't know how to install it.

Patrick.
 
C

Chris Angelico

Hi,
How can I install Python on Debian GNU/Linux? I downloaded the file
"Python-2.7.2.tar.bz2" but I don't know how to install it.

You should actually already have Python installed. Try typing 'python'
at a terminal and see if it invokes the interactive interpreter.

ChrisA
 
P

patrickwayodi

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".
 
C

Chris Angelico

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

If you don't have the compiler/build environment set up, you'll have
to do that first. If you aren't too concerned about the exact version
you get, the above apt-get line should get you a stable Python in the
2.7 branch.

ChrisA
 
S

Steven D'Aprano

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.
 
C

Chris Angelico

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`

Mea culpa, forgot that. Yes, use altinstall. Although it's probably
not a problem to replace 2.6.6 with 2.7.2 - I doubt that'll break many
things.

ChrisA
 
A

Anssi Saari

Christian Heimes said:
Except that all 3rd party extensions and packages are missing if you
install Python manually.

True, they would have to be built or at least installed manually also.
Major work, especially for a beginner. Shouldn't pick Debian Stable and
then want current software...

Then again, even the standard install of Python has plenty of stuff. I
installed 2.7.2 on my Debian system just to try out some of the new Tk
stuff.
Debian's backports should provide a well integrated Python 2.7
package.

But it doesn't. Python 2.7.2 is in Wheezy, which is the current testing
version of Debian. Looks like it has about 700 release critical bugs, so
it'll be a while until release.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top