RPY2 Is not working with multiple R versions Installed

We have recently upgraded our computing farm nodes from Ubuntu 10.04.4 to Ubuntu 12.04.3. We have user specific (/usr/bin) R & Pythons as well as network installed multiple versions of R(R-2.15.2, R-3.0.0), and pyhonbrew’s pythons(2.7.2,etc).We use RPY2(2.3.6) along with network installed R(R-2.15.2) and Python(2.7.2) which all are working fine until we updated Ubuntu. After the upgrade, using rpy2 throwing several different types of errors, some of them looks like:



Since our original rpy2 was build aginst old Ubuntu/R/Python shared libraries, we suspected that we may need to recompile it again to fix the rpy2 issues.

Thomas Cokelaer made a nice blog post on how to do this, This blog post is kind of extension to his solution.

So, I started off with re-installing rpy2 again.

First un-install rpy2:

This un-install only removing the file “<path_to_python>/lib/python2.7/site-packages/rpy2-2.3.6-py2.7.egg-info”, but not the entire rpy2 directory, so manually delete just to be sure:

Download RPY2

Set right environment variables:

Now recompile rpy2 against Intended R by specifying its location:

In most scenarios this should be good enough for rpy2 to work, however if you are unlucky like me, then read on..

After some frustrating hours of googling, un-re-installing rpy2, using different versions of python & R, I decided to dig further examining the shared objects that are used by running Python and R processes:

Then I looked at what shared objects are loaded particularly by “<path_to_r>/R-2.15.2/lib/R/bin/exec/R”:

As you can see from the output libR.so “libR.so => /usr/lib/libR.so (0x00007f2661c05000)” is loading from local R library instaed of my intended network R location.
This suppose to load like “libR.so => /software/R-2.15.2/lib/R/lib/libR.so (0x00007f328c64e000)”

Since, i don’t have admin privileges to touch network installed R or re-configure default SO’s, I fixed it by amending following environmental variable so that proper SOs are loaded:

After again re-installing rpy2 and testing, all works as intended:

Hope this helps to someone in the similiar situataion..

One thought on “RPY2 Is not working with multiple R versions Installed

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">