【问题标题】:rJava does not run on macOS SierrarJava 不能在 macOS Sierra 上运行
【发布时间】:2017-07-27 13:14:28
【问题描述】:

我使用的是 macOS Sierra 和 R 版本 3.4.0。 我使用 RStudio 安装了包“rJava”:

install.packages("rJava")
Warning in install.packages :
  cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/rJava_0.9-8.tgz'
Content type 'application/x-gzip' length 627959 bytes (613 KB)
==================================================
downloaded 613 KB


The downloaded binary packages are in
    /var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T//RtmpTdEVbA/downloaded_packages

然后当我尝试运行 rJava 时,我得到:

> require(rJava)
Loading required package: 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

【问题讨论】:

  • 不,我想使用 rJava 来运行 RNetLogo。
  • 看看在终端中执行R CMD javareconf能否解决问题。
  • 是的,我以前试过,现在又试了一次,没有任何运气。
  • 你试过从源代码安装吗? install.packages("rJava",type="source") 另见this related SO
  • 相关的SO解决了我的问题。我刚刚做了sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

标签: r rstudio macos-sierra rjava


【解决方案1】:

R、rJava 和 Java 在 macOS 中有点混乱。通常,您必须确保正确配置所有元素。 Oracle 和 Apple 的版本之间存在冲突。

在这里查看非常详细的说明:R, Java, rJava and macOS adventures

我不在这里发布内容 - 它很长。

【讨论】:

    猜你喜欢
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-12
    相关资源
    最近更新 更多