What is the fastest way to install Python 2.6 on an Ubuntu 8.04 server?

Posted on

What is the fastest way to install Python 2.6 on an Ubuntu 8.04 server? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ubuntu, apt, aptitude, .

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)

Solution :

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.

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.

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.

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.

Leave a Reply

Your email address will not be published.