Installing Python 2.6 on Ubuntu 8.04

I wanted to 'upgrade' my python from 2.5 to 2.6 on Ubuntu. Unfortunately, I could not find .deb packages 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.)

I have Python 2.5 installed and wanted to keep it, as Ubuntu 8.04 is a long term support version and I did not want to break this support by changing 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 for Python 2.5, because they seem to be identical to the build dependencies of 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 sunaudiodev is necessary for audio stuff on Sun. I'm wondering why Python tried to find 'the necessary bits to build these modules', as I don't run a 1.85 version of Berkeley DB, nor do I use Sun. Unfortunately, I could not find any documentation on how to switch off compiling these sources. I guess, 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 I can just delete, should I ever want to get rid of Python 2.6 (which I doubt).

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值