Resurrecting Python 2.4 on Ubuntu 12.10 • 25 Oct 2012
Should you ever need a Python 2.4 with MySQLdb running under Ubuntu 12.10 server, these are the hoops you have to jump through.
Steps
Start by installing a clean standard Ubuntu Server 12.10 i386, and execute these commands as root:
# Developer tools
apt-get update
apt-get install build-essential
# Database
apt-get install mysql-server # MySQL itself
apt-get install libmysqlclient-dev # Headers for compilation
# Compile the old Python
mkdir prj
cd prj
wget http://www.python.org/ftp/python/2.4.6/Python-2.4.6.tgz
tar -zxf Python-2.4.6.tgz
cd Python-2.4.6
nano Modules/Setup.dist # uncomment the line with 'zlib'
./configure
make
make altinstall # 'altinstall' to not overwrite the default Python
# There are now 3 versions of Python on the system:
python -V # The default python which came with Ubuntu.
python2.4 -V # Our just installed 'old' Python.
python3 -V # For the future ;-)
# Setuptools for Python 2.4
cd ~/prj
mkdir setuptools
cd setuptools
wget https://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg
sh setuptools-0.6c11-py2.4.egg
# MySQLdb connector for Python2.4
cd ~/prj
wget http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
tar -zxf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python2.4 setup.py install
# See if it works
cd ~
python2.4 -c "import MySQLdb; print dir(MySQLdb)"
# Does the database really work?
python2.4
>>> import MySQLdb
>>> con = MySQLdb.connect("localhost", "root", "secret") # The credentials you used during the MySQL installation
>>> cur = con.cursor()
>>> cur.execute("select 'Hooray!'")
1L
>>> r = cur.fetchone()
>>> r
('Hooray!',)
That's all there is to it.
Local mirror
If the above mentioned files disappear, I have them mirrored locally:
- MySQL-python-1.2.3.tar.gz (70K)
- Python-2.4.6.tgz (9M)
- setuptools-0.6c11-py2.4.egg (337K)