当我尝试通过 PyCharm 加载 rpy2
中的一些包(例如 importr
)时,代码如下:
from rpy2.robjects.packages import importr
我收到以下错误消息
ValueError: r_home is None. Try python -m rpy2.situation
最佳答案
确保您拥有 2.1.5 及更高版本(它们修复了其中 r_home 的问题)。
如果情况并非如此,也许这会有所帮助(摘自 here ):
If calling
initr()
returns an error stating thatR_HOME
is not defined, you should either have the R executable in your path (PATH
on unix-alikes, orPath
on Microsoft Windows) or have the environment variableR_HOME
defined. Should the initialization fail, a mismatch between the version of the R rpy2 was compiled against and the R rpy2 is run with should be investigated. The variablerpy2.rinterface.R_BUILD_VERSION
contains information about the R version rpy2 was built against. rpy2 is relatively independent of R versions, but changes in the R C API might cause problems.
关于python - 在 Windows 10 中安装后无法加载 'rpy2' 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57988996/