views:

111

answers:

2
A: 

First check that you installed rpy2 successfully. Look in /opt/local/var/macports/software for anything with rpy2 in the title. It maybe called py26-rpy depending on the version of Python you are running.

If you see that then you just need to use the right path to Python .. check the default location of Python like this:

which python

This will return the location of the first Python found and will probably say /usr/bin/python but you should use the version that rpy2 was compiled against.. which lives in /opt/local/bin.

Try:

/opt/local/bin/python2.6

then:

import rpy2
Martin Thomas
Thanks! @ S.Lott, yeah, I used sudo easy_instal rpy2 and it appeared to do *something* but then when I open up IDLE and import rpy2 I get a traceback error.
myClone
Also, @Martin: rpy2 is there. Where do I go to enter the "which python" statement? In python? In R? Confused. Do I need to install something on the R side of things first for this to work? Thanks...
myClone
@Martin--answered my first question--locate via Terminal. The location is here: /Library/Frameworks/Python.framework/Versions/2.6/bin/pythonNow what? It looks like I have two folders labeled py26-rpy2: one stored in /opt/local/var/macports/build and another stored in /opt/local/var/macports/logs.
myClone
Don't forget there may be multiple versions of Python installed. Start a terminal and type 'which python' and it will show you the version that will be run when you type python without a path in front. If you use locate, it will not observe your PATH variable and will just find the first match on the system.
Martin Thomas
A: 

easy_install and rpy2 work fine together (just did it) but you need to have easy_install in sync with your specific python version. This comes down to controlling your $PATH and $PYTHONPATH environment variables so that the first Python directory that appears is the version you want and also has the easy_install version you want. Do not try to solve this by taking out the factory installed version of Python.

You set your path variables in your home directory. If you are using the default bash shell, check .bash_profile for

$ echo $PYTHONPATH /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

which will tell you where and in what order installed packages are searched for

and

$ echo $PATH

/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:

Rather than giving a recipe for how to set these if needed, I encourage you to consult the usual sources because a little knowledge is dangerous and rendering the shell inoperative by reasonable, but wrong, guesses is a real danger.

Richard Careaga