Installing Python 2.6/3.0 without breaking stuff

ben
Sat, 23 Aug 2008 11:16:53 +0000

Pretty simple to do, but regardless here is a copy-and-paste'able set of commands that should work on OS X/Linux (if you have the Apple Developer Tools installed, or the build-essential package on Ubuntu):

cd /tmp/
curl -O http://www.python.org/ftp/python/2.6/Python-2.6b3.tgz
gunzip Python-2.6b3.tgz
tar -xf Python-2.6b3.tar
cd Python-2.6b3/
./configure --prefix=/usr/local/python2.6
# lots of lines ending in "... yes" hopefully
make
# will take a while, no errors
sudo make install
# enter your password, as it requires root access to put files in /usr/local/
# lots of stuff flies by..
sudo ln -s /usr/local/python2.6/bin/python2.6 /usr/local/bin/python2.6
sudo ln -s /usr/local/python2.6/bin/2to3 /usr/local/bin/2to3
# this puts python2.6 into your $PATH

That will install python2.6 into /usr/local/python2.6/ and symlink the commands python2.6 and 2to3 into /usr/local/bin/

Then you just run python2.6 /path/to/myscript.py

To see warnings about things that will break in Python3, run python2.6 -r /path/to/myscript.py