Installing Python 2.6 on Ubuntu 8.04

来源:互联网 发布:免费的vpn软件 编辑:程序博客网 时间:2024/06/05 01:51

I wanted to 'upgrade' mypython from 2.5 to 2.6 on Ubuntu. Unfortunately, I could not find .debpackages for Ubuntu. Fortunately, the Python 2.6 sources (sig) are available, so I can compile it from source. Here's what I had to do to get it running. (Short version: apt-get build-dep python2.5 and apply this patch to disable unavailable and outdated modules.)

Ihave Python 2.5 installed and wanted to keep it, as Ubuntu 8.04 is along term support version and I did not want to break this support bychanging to a maybe non-compatible Python version.

Python uses a configure-style installation procedure. First, extract the Python sources:

tar xzf Python-2.6.tgz
cd Python-2.6

I configured Python to stay out of my usual directories and install itself to /opt/python2.6:

./configure --prefix=/opt/python2.6
make

I thought that's all, however I get an error message like this:

Failed to find the necessary bits to build these modules:
_hashlib _ssl bsddb185
bz2 gdbm readline
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The easiest way to fix is to install the build dependencies forPython 2.5, because they seem to be identical to the build dependenciesof Python 2.6:

apt-get build-dep python2.5
make

However, there's still an error message:

Failed to find the necessary bits to build these modules:
bsddb185 sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

bsddb185 refers to the historic version 1.85 of Berkeley DB (now Oracle Berkeley DB), and sunaudiodevis necessary for audio stuff on Sun. I'm wondering why Python tried tofind 'the necessary bits to build these modules', as I don't run a 1.85version of Berkeley DB, nor do I use Sun. Unfortunately, I could notfind any documentation on how to switch off compiling these sources. Iguess, this could be improved.

Anyways, hacking setup.py was the way to go. Of course, it is not as easy as adding bsddb185 and sunaudiodev to the disabled_modules list at the beginning of setup.py. So I hacked the (bogus) test for the modules in detect_modules like the error message suggested, resulting in this patch.

patch -p1 < python2.6-disable-old-modules.patch
make
sudo make install

This installed python 2.6 into /opt/python2.6. Set up links to your bin directory, and you're done.

ln -s /opt/python2.6/bin/python2.6 ~/.root/bin/python-2.6
ln -s /opt/python2.6/bin/pydoc ~/.root/bin/pydoc-2.6

Usually, I use checkinstall,but this time everything is nicely packed into /opt/python2.6, which Ican just delete, should I ever want to get rid of Python 2.6 (which Idoubt).

Notes

The first time I ran, I got this message:

Failed to find the necessary bits to build these modules:
_hashlib _ssl bsddb185
bz2 gdbm readline
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

I think I found Ubuntu packages for some of them:

  • _hashlib and _ssl in libssl-dev
  • bz2 in libbz2-dev
  • gdbm in libgdbm-dev
  • readline in libreadline5-dev
原创粉丝点击