在“升级”之后,RStudio / R中的rJava加载错误到OSX Yosemite [英] rJava load error in RStudio/R after "upgrading" to OSX Yosemite

查看:206
本文介绍了在“升级”之后,RStudio / R中的rJava加载错误到OSX Yosemite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从OSX Mountain Lion升级到Yosemite,从R 3.1.3升级到3.2。在升级之后,当我打开R或RStudio时,我收到一条弹出消息,说我需要安装Java 6.此外,加载 rJava 或任何依赖的包在rJava上(例如, xlsx )导致RStudio崩溃(当我通过打开 R.app 尝试此操作时R也崩溃了直)。

I recently "upgraded" from OSX Mountain Lion to Yosemite and from R 3.1.3 to 3.2. Immediately after the upgrade, when I opened R or RStudio I got a pop-up message saying that I needed to install Java 6. In addition, loading rJava or any package that depends on rJava (e.g., xlsx) caused RStudio to crash (R also crashed when I tried this by opening R.app directly).

尝试在Stack Overflow和其他地方找到一些修复程序后(下面有更多详细信息),我正处于加载 rJava 或依赖于 rJava 的任何包不再导致R崩溃,但会导致以下错误:

After trying a few fixes found on Stack Overflow and elsewhere (more details below), I am at a point where loading rJava or any package that depends on rJava no longer causes R to crash, but results in the following error:

library(rJava)
Error : .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.2/Resources/library/rJava/libs/rJava.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: @rpath/libjvm.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so
  Reason: image not found
Error: package or namespace load failed for ‘rJava’

但是,如果我从命令行调用R然后loa d rJava 或依赖于 rJava 的任何包,它似乎有用(或至少我没有得到任何错误消息)。

However, if I invoke R from the command line and then load rJava or any package that depends on rJava, it seems to work (or at least I don't get any error messages).

我尝试了一些不同的尝试修复,其中一些已经修改了几次,并且不能完全记住我以什么顺序做了什么(没有意识到这将是一个混乱,并没有真正跟踪),但这是它的要点:

I've tried a number of different attempted fixes, some of them a few times, and can't quite remember exactly what I did in what order (didn't realize this would be such a morass and wasn't really keeping track), but here's the gist of it:


  • 在我的 .bash_profile 中添加了以下内容(根据此SO回答):

  • Added the following to my .bash_profile (per this SO answer):


export JAVA_HOME =/ usr / libexec / java_home -v 1.8

export LD_LIBRARY_PATH = $ JAVA_HOME / jre / lib / server

export JAVA_HOME="/usr/libexec/java_home -v 1.8"
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/server


  • 从命令行重新配置java,如下所示:

  • Reconfigured java from the command line as follows:


    sudo R CMD javareconf -n

    sudo R CMD javareconf -n


  • 已检查选项(java.home)并发现这被设置为 NULL 。我尝试将其设置为以下内容(根据此SO问题):

  • Checked options("java.home") and discovered this was set to NULL. I tried setting it to the following (per this SO question):


    options(java.home=/ Library / Java / JavaVirtualMachines / jdk1.8.0_45.jdk / Contents / Home / jre)

    options("java.home"="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre")


  • 安装最新的Java开发工具包并重新安装 rJava 来自消息来源(不记得我找到了哪一个)。

  • Installed the latest Java Development Kit and reinstalled rJava from source (can't remember where I found that one).

    在尝试的某个时刻所有这些,我能够加载 rJava 而不会崩溃R,而是收到上面发布的错误消息。此外,当我退出RStudio时,它似乎正常关闭,但随后会弹出RStudio意外退出消息,表明程序在尝试关闭时崩溃了。

    At some point while trying all of these, I was able to load rJava without crashing R, but instead got the error message posted above. In addition, when I quit RStudio, it would seem to close normally, but then an "RStudio quit unexpectedly" message would pop up, indicating that the program had crashed while trying to close.

    我终于决定安装 Java对于OS X 2014-001 (Java 6),因为我似乎没有选择。现在,当我打开R或RStudio时,此软件需要Java 6弹出消息不再出现。但是,我仍然在上面发布的'rJava'错误消息的loadNamespace()中遇到 .onLoad失败。

    I finally decided to install Java for OS X 2014-001 (Java 6), as I seemed to be running out of options. Now, when I opened R or RStudio the "This software needs Java 6" pop-up message no longer appeared. However, I was still getting the .onLoad failed in loadNamespace() for 'rJava' error message posted above.

    在回顾一些我已经看过的帖子时,我注意到我之前错过的另一个SO答案,建议使用以下命令行代码打开RStudio,为RStudio提供正确的java路径:

    In reviewing some of the posts I'd already looked at, I noticed another SO answer that I'd missed before, which recommended opening RStudio with the following command line code that gives RStudio the correct path to java:


    LD_LIBRARY_PATH = $(/ usr / libexec / java_home)/ jre / lib / server:open -a RStudio

    LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio

    这打开了一个RStudio窗口,我还能够加载 rJava 和依赖它的包而不会出错。

    That opened an RStudio window and I was also able to load rJava and packages that depend on it without getting an error.

    最后,我尝试从命令行运行R(我之前没有做过)。事实证明,在命令行上,加载 rJava 或依赖于 rJava 的任何包都可以运行并且不会抛出任何错误。

    Lastly, I tried running R from the command line (which I hadn't done before). It turns out that on the command line, loading rJava or any package that depends on rJava works and does not throw any errors.

    所以,如果我从命令行打开带有代码的RStudio,我现在可以得到 rJava 这给了RStudio java路径(如上所述)。但是,我想找到一种方法来解决潜在的问题,无论它是什么,这样就可以用通常的Mac方式打开RStudio,而不需要命令行kludge。我还担心安装旧版本的Java可能会导致问题。

    So, I can now get rJava to work if I open RStudio from the command line with the code that gives RStudio the java path (as noted above). However, I'd like to find a way to fix the underlying problem, whatever it may be, so that RStudio can be opened in the usual Mac way, without needing a command line kludge. I'm also concerned that having an old version of Java installed could cause problems down the road.

    有没有人对如何诊断和解决这个问题有任何想法?

    Does anyone have any ideas about how to diagnose and solve this issue?

    推荐答案

    我遇到了同样的问题,并且和你一样经历了同样的步骤。允许通过Finder / Spotlight启动RStudio的最后一步是将libjvm.dylib链接到/ usr / local / lib:

    I had the same problem and went through the same steps as you. The final step to allow starting RStudio through Finder/Spotlight was to link libjvm.dylib to /usr/local/lib:

    sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
    

    -f 添加标志以强制覆盖现有文件/链接

    -f flag is added to force overwriting existing file/link

    这篇关于在“升级”之后,RStudio / R中的rJava加载错误到OSX Yosemite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆