Update: 10/27/2011

I’m now on OS X Lion 10.7.2 and can confirm that the steps in this post will still get Python installed on your Mac.

Why Did I Replace the Default Python on Mac OS X?

Skip to the tutorial

Mainly, because tests were failing in my Django web application on my Mac that were passing on my Ubuntu setup. So I set out to create an up-to-date Python development environment on my Mac that works the same as the one on my Ubuntu box. Having successfully put Python 2.6.6 from python.org on my Mac, and fixed my web app, I’m sharing my results, setup, and solution with community.

Other Reasons to Replace the Python That Ships with Mac OS X

Python Interpreter Output: sys.maxint and sys.maxunicode

python -c "import sys; print sys.maxint;"
  • 9223372036854775807 (64-bit)
  • 2147483647 (32-bit)
python -c "import sys; print sys.maxunicode"
  • 1114111 (UCS-4)
  • 65535 (UCS-2)

Tutorial: How I Built Python 2.6.6 (64-bit) on Mac OS X

See also: Which Version of Python Do You Already Have Installed on Mac OS X? (Opens in a new Window)

  1. Install XCode from the Snow Leopard DVD
  2. Edit the first two lines of your .bash_profile to be:
    export PATH
  3. Download Python 2.6.6 source code:
    curl -O http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz
    tar -xvf http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz
    cd Python-2.6.6
  4. Edit /etc/paths and move the following line to the top of the file
  5. ./configure --disable-framework --disable-toolbox-glue \
    OPT="-fast -arch x86_64 -Wall -Wstrict-prototypes -fno-common -fPIC" \
    --enable-unicode=ucs4 LDFLAGS="-arch x86_64"
  6. make
  7. sudo make install
  8. cd into your home directory and type:
    source .bash_profile
  9. Open an interactive interpreter session, and if I’ve been successful in my instructions, you’ll see the following with different date/time information:
    Python 2.6.6 (r266:84292, Jan 30 2011, 21:45:16)
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.