Skip navigation

This is how I created a tarball that, when extracted, gives a fully functioning install of python 2.6 w/ mysql – while leaving all of the original binaries in place.  The destination of the tarball must be decided at compile time. You may need to recreate the tarball if any of the software packages this is based on (the *-devel packages found below) are upgraded.

The creation process will modify the build server, though the resulting tarball will be completely clean (can be untarred into any similar server with identical software versions and file locations without modification).   You may want to wipe your environment after successfully testing deployment.

export CDIR=/opt/python-2.6
mkdir py-tmp && cd py-tmp
# get needed libraries
# if any of these fail to install for whatever reason, you will need to grab the source for the closest available version to what is running on your system, and install it manually into its standard location (specific examples found below).
yum install -y wget zlib-devel openssl-devel readline-devel mysql-devel gcc-c++

# now for Python itself
wget (get your own updated link)
tar xf Python-2.6.*.tgz
cd Python-2.6.*
./configure --prefix=$CDIR
make install
cd ..

# install setuptools (easy_install)
wget (get your own link)
sh setuptools-*.egg

# install the coveted mysql-python package
wget (get your own link)
tar xf MySQL-python-*.tar.gz
cd MySQL-python-*
$CDIR/bin/python build
$CDIR/bin/python install
cd ..

tar -czf python-2.6.tgz $CDIR

tar -xzf python-2.6.tgz -C /

To use this python binary, you can modify your $PATH, adding $CDIR/bin before /usr/bin or wherever your other version is installed. To make a python script use this version, either specify the full path on the scripts #! line, or run $CDIR/bin/python script.

If any of the libraries fail to install (possibly due to crufty servers), you will need to install them manually to their standard location. Here are some examples of what I've had to do. Be sure to grab the same version of the software as is already installed.

tar -xjf zlib-1.2.3.tar.bz2
cd zlib-1.2.3
make install
cd ..

tar -xzf openssl-0.9.7a.tar.gz
cd openssl-0.9.7a
make install
cd ..

Here is something quite important: if you cannot install mysql-devel, I recommend just grabbing the devel rpm from Be sure that the mysql version matches as closely as possible to that installed in your system (the version should be spit out when you try to run yum install mysql-devel). Also, the glibc version must match your system exactly.

yum install Mysql-devel*

One Trackback/Pingback

  1. […] Python 2.6+MySQL for CentOS/RedHat/Fedora […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.