Debian – How to install Python 3.x on Debian

debianpackage-managementpython

Being new to Linux, I chose Debian for my Linode because it seemed stable and secure. Now I want to write some sysadmin-type scripts in Python to teach myself the language. Based on this SO question I've decided to go with Python 3. At very least, I'd like my Linode to have 2.6 or 2.7 because that's what's installed on my home machines. But the default for Debian is still 2.5.

That's fine, but for the life of me I cannot figure out how to get the python3.1 package!! It's driving me nuts!

Here's a sample of what I've tried (after running apt-get update to make sure my package index was up to date):

$ apt-cache search ^python$
python - An interactive high-level object-oriented language (default version)
$ apt-cache search ^python3$
$ apt-cache search ^python*$
python - An interactive high-level object-oriented language (default version)
$ apt-cache -a search ^python*$
python - An interactive high-level object-oriented language (default version)
$ apt-cache search ^python2\.4$
python2.4 - An interactive high-level object-oriented language (version 2.4)

I know that this package is available because I can see it right there on debian.org. How do I find it and install it?

And after I finally figure out how to install the latest Python, am I still going to have trouble from my package manager when installing things that depend on Python? Are they going to point to the default python instead of the one I want? I'd much rather use the native package manager than use easy_install (see the reason I care about packages here).

Oh, and I am looking for a command-line-only answer.

Best Answer

I'm going to assume you've got Debian lenny and have your sourcelist geared towards the stable release which by default only has python2.5 (someone correct me?)

From a brief scan of their package tree, python3.1 exists in the Debian Sid (unstable) and Debian Squeeze (testing) tree. See Here

You can w-get directly from the links provided, but that's often messy as you'll need to resolve any dependencies yourself through a game of what don't I have? with the CLI.

If you're apt for switching your package tree to squeeze, you can change your /etc/apt/sources.list to match that of the squeeze tree. From there, you can aptitude update then aptitude install python and you should have python3.1 and all its dependencies in tow.

Related Question