无法在Mac上安装qdap的库功能

时间:2018-09-03 20:41:20

标签: r

我正在R Studio上的一个项目上工作,在Mac上安装qdap并运行库函数时收到错误消息。

这就是我所得到的。

install.packages('qdap')
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/qdap_2.3.0.tgz'
Content type 'application/x-gzip' length 4164745 bytes (4.0 MB)
==================================================
downloaded 4.0 MB


The downloaded binary packages are in
    /var/folders/0v/c58lzwxd513g64xxc0gd85rm0000gn/T//RtmphbntNA/downloaded_packages
> library('qdap')
Error: package or namespace load failed for ‘qdap’:
 .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.5/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
  Reason: image not found

1 个答案:

答案 0 :(得分:0)

我发现问题是R无法正确定位Java_home。

要遵循的步骤:

  1. 如果尚未下载并安装Java JDK,则为
  2. 在终端中,通过键入which java
  3. 查找Java位置。
  4. 将R中的JAVA_HOME设置为Sys.setenv("JAVA_HOME" = 'your java location such as /usr/bin/java')
  5. 尝试重新安装软件包openNLP,rJava和qdap。