Install PyMC on OSX, Python2.7

I came across a number of compile problems when trying to install PyMC with the latest STSCI_PYTHON and Python2.7. The main problem appears to stem from the version of gfortran that the install scripts found in /sw/bin, perhaps shipped with Apple developer tools. I found a fix by forcing /usr/local/bin/gfortran, which you can obtain from HERE.

cd /sw/bin
sudo mv gfortran gfortran-xx

Then to install:

cd /usr/local/share/  ### place to store downloaded source code

### Get source from
cd pymc-2.1beta

csh  ### Hack to use the STSCI_PYTHON environment variables

export F77=/usr/local/bin/gfortran   ### Make sure to use the correct gfortran
ARCH="-arch x86_64"                  ### The following seem to be necessary for building PyMC with
export CFLAGS="${ARCH}"
export FFLAGS="-static -ff2c ${ARCH}"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle ${ARCH}"

### Run the build script
rm -rf build
python config_fc --fcompiler gfortran build

### Put it somewhere in PYTHONPATH
sudo cp -R build/lib.macosx-10.6-x86_64-2.7/pymc /usr/stsci/pyssgx/Python-2.7/lib/python2.7/site-packages/

Without the “-arch” commands above that force 64-bit compilation with x86_64, Python2.7 chokes with an error like:
/usr/stsci/pyssgx/Python-2.7/lib/python2.7/site-packages/pymc/ mach-o, but wrong architecture because the library was compiled with i386, e.g.:

lipo -info /usr/stsci/pyssgx/Python-2.7/lib/python2.7/site-packages/pymc/
Non-fat file: /usr/stsci/pyssgx/Python-2.7/lib/python2.7/site-packages/pymc/ is architecture: i386

Finally, test it with the simple example script listed at .

This entry was posted in install, Tips, Uncategorized and tagged , , . Bookmark the permalink.

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