4

I am trying to use the magic command in ipython, something I saw here: rpy2 slides

I have done the following:

import rpy2.ipython
%load_ext rpy2.ipython

But I get the following error:

ImportError: dlopen(/Users/XXX/anaconda/lib/python2.7/site-packages/rpy2/rinterface/_rinterface.so,

2): Library not loaded: libicuuc.54.dylib Referenced from: /Users/XXX/anaconda/lib/python2.7/site-packages/rpy2/rinterface/_rinterface.so Reason: image not found

Some relevant information:

  • OS: MacOS Sierra
  • Python: 2.7.12
  • iPython: IPython 5.1.0
  • rpy2: 2.8.3
  • Did the pip install singledispatch but the error still persists
  • r installed using conda
  • Also have a copy of R from CRAN
Rohit
  • 5,840
  • 13
  • 42
  • 65

1 Answers1

7

Because I installed R through conda, I also needed to install rpy2 through conda and not through pip. To install rpy2 through conda do the following,

conda install -c r rpy2

This worked really well. However, it is unclear why installing rpy2 through pip does not work.

Rohit
  • 5,840
  • 13
  • 42
  • 65
  • installing rpy2 thru pip utilizes your local installation of R. If rpy2 doesn't find R in your path variable or doesn't like it it will throw an error. On the other hand conda's rpy2 installs an independent version or R. When you run the `conda install -c r rpy2` you'll notice the base R packages installing. As a result you'll need to install any additional packages you want to use into the rpy2 copy of R. This is the main reason why the conda install is more stable. – hussam Sep 29 '18 at 02:37