Q: Integrating Python with R 
*

*I am trying to install the appropriate packages to allow easy access to R from Python.

*From what I understand, I have to use a command called easy_install to install a program called py2

*But to do that, I have to install easy_install by running a .egg file downloaded as if it were a shell script.
How do I run my downloaded file as if it were a shell scirpt? And once I have done that, if I just run easy_install py2, will the R interface be installed.
Appropriate links are here:


*

*http://rpy.sourceforge.net/rpy2_download.html

*http://peak.telecommunity.com/DevCenter/EasyInstall

*http://pypi.python.org/pypi/setuptools

A: I suggest installing pip, an alternative to easy_install, first. 
I am not sure what tools OSX comes with for downloading the bootstrap code for pip (curl, wget), but I assume you have python 2.X installed, which you can check with 
python --version

Run the following python program, by saving this as download.py and then run 'python download.py':
import os
import urllib2
from subprocess import call

def download_file_and_run(url):
    basename = os.path.basename(url)
    fp = urllib2.urlopen(url)
    open(basename, 'wb').write(fp.read())
    fp.close()
    call(['python', basename])

download_file_and_run('http://python-distribute.org/distribute_setup.py')
download_file_and_run('https://raw.github.com/pypa/pip/master/contrib/get-pip.py')

now
pip --version 

should give you a version number like 1.1
Now install rpy2 using:
pip install rpy2

This assumes R is installed, if not the installer will complain with an error:
Tried to guess R's HOME but no R command in the PATH.
