How to set the R_HOME environment variable to the R home directory?

后端 未结 2 471
小鲜肉
小鲜肉 2021-01-04 18:21

I am trying to import rpy2 into python and I am getting this error:

RuntimeError: The R home directory could not be determined.
Try to install R 

        
相关标签:
2条回答
  • 2021-01-04 18:55

    It is the other way around -- the R in your PATH should know its home:

    edd@don:~$ R RHOME
    /usr/lib/R
    edd@don:~$ 
    

    This echos the last line recommendation -- have your R in the PATH.

    On another machine with both R and R-devel, I choose to address the latter under a different name. Still, each knows its HOME:

    edd@max:~$ /usr/local/lib/R-devel/bin/R RHOME
    /usr/local/lib/R-devel/lib/R
    edd@max:~$ R RHOME
    /usr/lib/R
    edd@max:~$ 
    
    0 讨论(0)
  • 2021-01-04 19:03

    Setting R_HOME this way worked for me

    import os
    os.environ['R_HOME'] = '/path/to/R'
    
    0 讨论(0)
提交回复
热议问题