Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home How To Python Installing rpy2 on OS X (Python 2.x)

Installing rpy2 on OS X (Python 2.x)

This is probably the "easiest" way to install rpy2 on OS X.


Usually the bottleneck is getting a good R install with your rpy2 pointing to the correct R shared libraries. I have made this approach work with Python 2.6, but a similar approach will probably work with Python 3.x.

Note that all of the so-called "literal text" are commands that should be typed into the terminal (e.g. /Applications/Utilities/Terminal.app).

 

  1. If not already present under "/Developer/" on your computer, install XCode from the install disks that came with your computer, or try to get XCode from the App store.
  2. Make an R installation directory and download the appropriate R source into it.
  3. mkdir -p ~/Installers/R
    cd ~/Installers/R
    wget http://cran.stat.ucla.edu/bin/macosx/old/R-2.13.2.pkg
  4. Open the package and install it.
  5. open ./R-2.13.2.pkg

    The installer will pop up. It will take a few minutes to install and may even appear to stall very late in the installation. But it should eventually succeed.

  6. Make sure you have the latest easy_install for your python.
  7. mkdir -p ~/Installers/python-modules/easy_install
    cd ~/Installers/python-modules/easy_install
    wget http://peak.telecommunity.com/dist/ez_setup.py
    sudo python ez_setup.py -U setuptools
  8. Use easy_install to install rpy2 (with luck it will work).
  9. sudo easy_install rpy2
  10. Now make sure that you have set the "R_HOME" environment variable to point to the R you just installed
  11. For bash users:

    echo 'R_HOME="/Library/Frameworks/R.framework/Versions/Current/Resources/"; export R_HOME' >> ~/.bashrc

    For tcsh users:

    echo 'setenv R_HOME "/Library/Frameworks/R.framework/Versions/Current/Resources/"' >> ~/.tcshrc

    If you are so cool that you have to use zsh, then you are too cool to need instructions on how to set your environment variables.