如何将 R_HOME 环境变量设置为 R 主目录? [英] How to set the R_HOME environment variable to the R home directory?

查看:63
本文介绍了如何将 R_HOME 环境变量设置为 R 主目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 rpy2 导入 python,但出现此错误:

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 <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.

我完全迷失在这里,因为我不知道这在告诉我什么.我试图搜索如何设置环境变量,但找不到任何对我有帮助的足够详细的信息.如果答案非常简单,我将不胜感激,因为我只是一个新手.我正在运行 OSX 10.11.

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.

谢谢(我的第一篇文章,如果我忽略了发布规则,我深表歉意)

Thank you (my first post, I apologize if I overlooked any rules in posting)

推荐答案

这样设置 R_HOME 对我有用

Setting R_HOME this way worked for me

import os
os.environ['R_HOME'] = '/path/to/R'

这篇关于如何将 R_HOME 环境变量设置为 R 主目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆