Search code examples
pythonrrpy2

Import rpy2 : unable to determine R library path


I would like to import rpy2 to load R package

from rpy2.robjects.packages import importr

I have an error:

Unable to determine R library path: Command '(...Miniconda3\\lib\\R\\bin\\Rscript', '-e', 'cat(Sys.getenv("LD_LIBRARY_PATH"))')' returned non-zero exit status 1.

python can't find the right R path.


Solution

  • I recently ran into this issue as well. From what I can tell, it seems to be related to the current distribution of rpy2 (3.5.2). I was able to resolve this issue by installing an earlier version of the package:

    pip install rpy2==3.4.5