I try to install rpy2 in my system, (I compile R with --enable-R-shlib and with --enable-BLAS-shlib flags) but when I try in python console

import rpy2
import rpy2.robjects

I got:

Traceback (most recent call last):
    File "<stdin>", line 1, in<module>
    File "/usr/lib/python2.6/dist-packages/rpy2/robjects/__init__.py",
 line 14, in<module>
      import rpy2.rinterface as rinterface
    File "/usr/lib/python2.6/dist-packages/rpy2/rinterface/__init__.py",
 line 75, in<module>
      from rpy2.rinterface.rinterface import *
 ImportError: libRblas.so: cannot open shared object file: No such file
 or directory

The rpy2 directory is:



My R version is:

R version 2.12.1 Patched (2011-01-04 r53913)

My R home is:


My ubuntu version is:

Linux kenneth-desktop 2.6.32-27-generic #49-Ubuntu SMP Thu Dec 2 00:51:09 UTC 2010 x86_64 GNU/Linux

My Python version is:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2

When I install rpy2 from source (sudo python setup.py build install) I got:

running build
running build_py
running build_ext
Configuration for R as a library:
   include_dirs: ('/usr/lib64/R/include',)
   libraries: ('R', 'Rblas', 'Rlapack')
   library_dirs: ('/usr/lib64/R/lib',)
   extra_link_args: ()
  # OSX-specific (included in extra_link_args)
   framework_dirs: ()
   frameworks: ()
running install
running install_lib
running install_data
running install_egg_info
Removing /usr/local/lib/python2.6/dist-packages/rpy2-2.1.9.egg-info
Writing /usr/local/lib/python2.6/dist-packages/rpy2-2.1.9.egg-info

What am I doing wrong?

Thank you for your help.


It looks like you tried to do things locally but didn't quite get there. I happen to maintain the Debian packages of R (which get rebuilt for Ubuntu and are accessible at CRAN. These builds use external BLAS. rpy2 then builds just fine as well.

I would recommend that you read the README, try to install r-base-core and r-base-dev from the repositories and then try to install rpy2 from source. Or live with the slightly older rpy2 package in Ubuntu.


For others running into this issue, I was able to solve it by making sure to add the R libraries to my library path in bashrc:

export LD_LIBRARY_PATH="R-install-location/lib65/R/lib:$LD_LIBRARY_PATH"

Not the answer you're looking for? Browse other questions tagged or ask your own question.