R:rJava 包安装失败 [英] R: rJava package install failing

查看:59
本文介绍了R:rJava 包安装失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 install.packages("rJava") 命令安装 rJava 时,出现以下错误:

When installing rJava using the install.packages("rJava") command I get the following error:

checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../include -I/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server -L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64 -L/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib -ljvm'
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’

我安装了 Java JDK 并且 java -version 返回以下内容:

I have the Java JDK installed and java -version returns the following:

$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)

当谷歌搜索错误时,我发现其他人也有同样的问题,但除了我已经完成的安装整个 JDK,而不仅仅是 JRE"之外,没有找到解决方案.

When Googling around for the error I see that others are having the same issue but not finding a solution other than "install the whole JDK, not just the JRE" which I have done.

我读到的另一件事是运行 sudo R CMD javareconf,它运行得很愉快,没有错误.

The other thing I read was to run sudo R CMD javareconf which runs quite happily with no errors.

知道我的问题是什么吗?

Any ideas what my problem is?

[]我已经有几个月没有遇到这个问题了.我最初通过编辑我的 Java 路径解决了这个问题,如我在下面发布的答案中所示.我最近在新的 Ubuntu 安装中遇到了同样的问题.我尝试了 Dirk 的推荐使用 apt-get 来安装 rJava 包.它工作得很好.我最初没有意识到的是,使用 Ubuntu apt-get 方法安装软件包与仅使用 R 中的 install.packages() 加载相同的软件包有着根本的不同. Ubuntu 软件包解决了一些我没有意识到或没有意识到的问题.

[] It's been a few months since I had this problem. I had initially solved this by editing my Java paths, as illustrated in the answer I posted below. I recently ran into the same issue on a new Ubuntu install. I tried Dirk's recommendation to use apt-get to install the rJava package. It worked perfectly. What I failed to appreciate initially is that installing packages using the Ubuntu apt-get method is fundamentally different than just loading the same package using install.packages() inside of R. The Ubuntu packages solve some issues which I didn't realize or appreciate.

推荐答案

原来我的问题是我的 JAVA_HOME 环境变量的问题.是的,我知道令人震惊.我对 PATHJAVA_HOME 的初始设置如下所示:

Turns out my problem was an issue with my JAVA_HOME environment variable. Yes, shocking I know. My initial setting for PATH and JAVA_HOME looked like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

我添加了 /jre 所以它现在看起来像这样:

And I added /jre so it now looks like this:

export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export PATH=$PATH:$JAVA_HOME/bin

如果没有 /jre,Java 中的一切似乎都可以正常工作,但 rJava 则不行.奇怪的.

Everything in Java seemed to work fine without the /jre but rJava would not. Odd.

这篇关于R:rJava 包安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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