I am trying to import rpy2 into python and I am getting this error:
我正在尝试将rpy2导入到python中,我得到了这个错误:
RuntimeError: The R home directory could not be determined.
Try to install R <https://www.r-project.org/>,
set the R_HOME environment variable to the R home directory, or
add the directory of the R interpreter to the PATH environment variable.
I am completely lost here as I have no idea what this is telling me. I tried to search up how to set the environment variable and couldn't find anything detailed enough that was helpful for me. I would appreciate it if the answer could be very straightforward as I am just a newbie. I am running OSX 10.11.
我完全迷失在这里,因为我不知道这告诉我什么。我试图查找如何设置环境变量,但找不到任何对我有帮助的细节。如果我是个新手,我希望答案能很简单。我正在运行OSX 10.11。
Thank you (my first post, I apologize if I overlooked any rules in posting)
谢谢你(我的第一个帖子,如果我在发帖时忽略了任何规则,我向你道歉)
2 个解决方案
#1
3
It is the other way around -- the R in your PATH
should know its home:
相反,在你的道路上,R应该知道它的家:
edd@don:~$ R RHOME
/usr/lib/R
edd@don:~$
This echos the last line recommendation -- have your R in the PATH
.
这是最后一行的推荐——让你的R在路径中。
On another machine with both R and R-devel, I choose to address the latter under a different name. Still, each knows its HOME
:
在另一台同时使用R和R-devel的机器上,我选择使用不同的名称来处理后者。然而,每个人都知道自己的家:
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:~$
#2
0
Setting R_HOME this way worked for me
这样设置R_HOME对我来说很有用
import os
os.environ['R_HOME'] = '/path/to/R'
#1
3
It is the other way around -- the R in your PATH
should know its home:
相反,在你的道路上,R应该知道它的家:
edd@don:~$ R RHOME
/usr/lib/R
edd@don:~$
This echos the last line recommendation -- have your R in the PATH
.
这是最后一行的推荐——让你的R在路径中。
On another machine with both R and R-devel, I choose to address the latter under a different name. Still, each knows its HOME
:
在另一台同时使用R和R-devel的机器上,我选择使用不同的名称来处理后者。然而,每个人都知道自己的家:
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:~$
#2
0
Setting R_HOME this way worked for me
这样设置R_HOME对我来说很有用
import os
os.environ['R_HOME'] = '/path/to/R'