4

I just got an Ubuntu server set up, and it seems to have come with Python 2.5. I've been developing my app in Python 2.6, but apt-cache search ^python seems to not contain 2.6. What is the fastest way to update the repositories apt-get looks through to include one that has Python 2.6?

(Answer mixed in reply/reply-comments: fastest way is to upgrade to Ubuntu 9.04 or later)

7 Answers 7

7
apt-get update; apt-get install python2.6

works for me [ jaunty ], but you might have older version of ubuntu. fiddle a bit with /etc/apt/sources.list and apt-get distr-upgrade as described here.

2
  • Didn't work for me on Ubuntu 8.04.2, but the fiddling did. Jun 16, 2009 at 17:59
  • Worked on 9.04 like a charm (but didn't need to because it was standard). Jun 17, 2009 at 0:32
6

There is a Python 2.6 package for Ubuntu, http://packages.ubuntu.com/search?keywords=python2.6, but only for the jaunty and karmic releases. You could possibly grab the .deb file and install it on previous versions, but things may break..

If apt-get fails you, compiling from source is trivial:

# change this to latest on http://python.org/download/
PY_TWOSIX="http://python.org/ftp/python/2.6.2/Python-2.6.2.tgz"

# Required to compile anything - this is the only Ubuntu specific line
sudo apt-get install build-essential

# Download/extract the Python source file set in PY_TWOSIX
cd /tmp/
wget $PY_TWOSIX -O py.tgz
gunzip py.tgz
tar -xf py.tar
cd Python-*

# Configure, build and install it into /usr/local/python/2.6.2/
./configure --prefix=/usr/local/python/2.6.2
make
sudo make install

# Link python binary into /usr/local/bin/ as python2.6
sudo ln -s /usr/local/python/2.6.2/bin/python /usr/local/bin/python2.6
# you can also at add the directory to your $PATH rather than using sym-links

Of course you should try and install everything via your package manager (so you get automatic updates and such), but I tend to keep old versions of Python around, and putting them in /usr/local/python/ shouldn't interfere with apt-get at all.

0
6

If a package is not available in your version of Ubuntu, it's fairly easy to backport the package from a more recent version. For example:

Let's start by installing some packages required for building any package:

apt-get install build-essential devscripts

Next we get the source packaging. In this case we go to http://packages.ubuntu.com/jaunty/python2.6 and look on the right and see three links under "Download Source Package". You should end up with a .tar.gz, .diff.gz and a .dsc file.

Next we unpack the source:

dpkg-source -x python2.6_2.6.2-0ubuntu1.dsc

This will extract everything into a directory. If you change into that directory and see if we can build it with the packages we currently have installed.

debuild -us -uc -b

This will either take some time and build you some packages in the directory above the source directory. Alternatively it will complain about missing build dependencies. If you're lucky, you can just install them and try building the package again. If you're unlucky, the package requires an updated package. You can try following the same procedure to build the build dependency or you can try changing the dependency version in debian/control. I'd only do the latter if you discover you're ending up building too many packages as the packaging hasn't been tested with those changes.

Once you've got your packages, you can run

dpkg -i foo.deb bar.deb

If it complains about dependencies, you can run:

apt-get install -f

which should sort out your dependency problems. If it doesn't, you may need to back port more packages.

2
  • +1 If you must build from source, this is the usually the best way to do it on a ubuntu/debian system.
    – Zoredache
    Jun 6, 2009 at 20:19
  • Could not get this to work---generated packages require a python2.6-minimal, which is not created... Apr 26, 2010 at 0:14
1

In Ubuntu 8.04, you might need to find a port repo to apt-get. So it's recommended to install with source code. In Ubuntu 9.04 and 10.04, python2.6 is standard.

0

What version of Ubuntu is it? There's an (admittedly very old) post on StackOverflow here which suggests you have to do it from source, but it depends on your version: here

0

optionally, you can open synaptic, refresh packages and search for python2.6. I always prefer using synaptic.

1
0

The following worked for me with little variation:

% sudo apt-get install python2.6-minimal

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .