R warnings when starting rpy2 and installation

On Fedora 15

When I start rpy2 using this command

import rpy2
from rpy2 import robjects

I was getting these annoying warnings, which do not appear when starting a pure R session:

During startup - Warning messages:
1: package ‘methods’ was built under R version 2.15.1 
2: package ‘datasets’ was built under R version 2.15.1 
3: package ‘utils’ was built under R version 2.15.1 
4: package ‘grDevices’ was built under R version 2.15.1 
5: package ‘graphics’ was built under R version 2.15.1 
6: package ‘stats’ was built under R version 2.15.1

I decided to install the newest version of R (2.15.2), which is not available under my current distribution (Fedora 15). So, I got the source files from the R web page and unpack the source into a directory. I then configure and compile it:

./configure --enable-R-shlib
make

Then, just type

make install

Note: I first started without the –enable-R-shlib option and abruptly stop the compilation to reconfigure. After typing make and waiting a while I got this error:

/usr/bin/ld: CConverters.o: relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
  CConverters.o: could not read symbols: Bad value
  collect2: ld returned 1 exit status

The solution was to restart the installation from scratch.

Then, I started ipython and tried to import rpy2 again but got an error related to a missing libR.so (despite the usage of –enable-R-shlib option)

>>> import rpy2.robjects
ImportError: libR.so: cannot open shared object file: No such file or directory

quit ipython and fix the issue by telling your system where to find the library (use locate libR.so):

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64/R/lib/

Starting again ipython and the rpy2 import, I got another error message….:

>>> import rpy2.robjects
cannot find system Renviron
Fatal error: unable to open the base package

Here, the R_HOME is missing:

R_HOME=/usr/local/lib64/R

and now everything seems to work without warnings, which was the original issue…

Please follow and like us:
error
This entry was posted in Computer Science and tagged , . Bookmark the permalink.

4 Responses to R warnings when starting rpy2 and installation

  1. Arulraj Anto says:

    [root@sys-1605 ~]# python -c “import rpy2.robjects”
    Traceback (most recent call last):
    File “”, line 1, in
    File “/usr/local/python2.7/lib/python2.7/site-packages/rpy2/robjects/__init__.py”, line 12, in
    import array
    ImportError: /usr/local/python2.7/lib/python2.7/lib-dynload/array.so: undefined symbol: PyUnicodeUCS2_FromUnicode

    Please help me to resolve this issue.

  2. Arulraj Anto says:

    [root@sys-1605 lib]# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/R-2.15.2/lib64/R/lib/
    [root@sys-1605 lib]# python
    Python 2.7.11 (default, Apr 7 2016, 19:08:08)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import rpy2.robjects
    Traceback (most recent call last):
    File “”, line 1, in
    File “/usr/local/python2.7/lib/python2.7/site-packages/rpy2/robjects/__init__.py”, line 12, in
    import array
    ImportError: /usr/local/python2.7/lib/python2.7/lib-dynload/array.so: undefined symbol: PyUnicodeUCS2_FromUnicode
    >>>

  3. Anonymous says:

    I just wanted to say, I’ve come back to this post several times when I’ve hit problems with rpy. Very helpful post, thank you!

  4. Anonymous says:

    Thank you!

Leave a Reply

Your email address will not be published.