在Mac中安装好rJava
后用 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 '/Users/zgxu/Library/Rlib/rJava/libs/rJava.so':
dlopen(/Users/zgxu/Library/Rlib/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Users/zgxu/Library/Rlib/rJava/libs/rJava.so
Reason: image not found
根据我的推断,应该是环境变量JAVA_HOME
的设置问题,于是通过检索,找到MacOS的Java实际路径/Library/Java/JavaVirtualMachines/JDK版本号/Contents/Home
所以我在~/.bashrc
中增加了下面的
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/jre"
不再报错,开心。
网友评论