问题描述
这是我得到的错误:
> library(rJava)
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
我认为这绝不是一个唯一的问题..我已经尝试过解决方案,此处和此处.没有成功.
I see this is by no means a unique problem.. I've tried the solutions here, here and here. No success.
更多详细信息:我正在使用R GUI,但是我也无法通过R终端加载rJava.我在R 3.3.s上的rJava也没有任何问题
Some more details: I'm using R GUI, but I also can't load rJava through R terminal. I also didn't have any issue with rJava on R 3.3.s
推荐答案
JAVA_HOME路径对于不同版本的MAC OS是不同的.在某些情况下,存在/jre
文件夹,并且在某些情况下,不是在/Home
控制器在终端中使用CD
命令手动转到/server
文件夹并使用pwd
复制整个路径后,使用该路径设置java.home
,则可以轻松加载rJava
库.这就是我能够解决此问题的方式
JAVA_HOME path is different for different version of MAC OS.In some cases there is /jre
folder and in some cases it is not after /Home
director manually go towards /server
folder with CD
command in terminal and using pwd
copy the entire path use that to set the java.home
then you can easily load rJava
library. This is how I was able to fix the issue
options("java.home"="/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib")
Sys.setenv(LD_LIBRARY_PATH='$JAVA_HOME/server')
dyn.load('/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
library(rJava)
这篇关于无法在R 3.4.2和MacOS Sierra 10.12.6中加载rJava的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!