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)

Andrey Fedorov
  • 2,129
  • 4
  • 16
  • 12

7 Answers7

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.

pQd
  • 29,981
  • 6
  • 66
  • 109
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.

dbr
  • 1,568
  • 3
  • 16
  • 18
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.

David Pashley
  • 23,497
  • 2
  • 46
  • 73
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

JamesHannah
  • 1,731
  • 2
  • 11
  • 24
0

The following worked for me with little variation:

% sudo apt-get install python2.6-minimal
slm
  • 7,615
  • 16
  • 56
  • 76
Milan
  • 101
0

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

user1289167
  • 103
  • 4
  • Maybe you could provide a little more details about how to accomplish this? [How to Answer a Question Guide](http://serverfault.com/questions/how-to-answer) – slm Apr 19 '13 at 06:01