加载rJava时出错 [英] Error while loading rJava
问题描述
当我想加载rJava时出现错误。 JDK已安装。 (我在CentOS VM上运行R(cloudera demo vm cdh3u4))
>库(rJava)
错误:.onLoad在loadNamespace()中为'rJava'失败,详细信息:
call:dyn.load(file,DLLpath = DLLpath,...)
错误:无法加载共享对象'/home/cloudera/R/x86_64-redhat-linux-gnu-library/2.15/rJava/libs/rJava.so':
libjvm.so:无法打开共享对象文件:没有这样的文件或目录
错误:'rJava'的包/命名空间加载失败
LD_LIBRARY_PATH
设置有什么问题吗?如果是,我该如何解决?
更多信息(如果需要):
[cloudera @ localhost〜] $ java -version
java版本1.6.0_31
Java(TM)SE运行时环境(版本1.6.0_31-b04 )
Java HotSpot(TM)64位服务器VM(构建20.6-b01,混合模式)
让rJava工作取决于您的计算机配置。以下内容至少在 Windows 平台上有效。
- 您必须使用相同的 strong> 32位或64位版本:R 和 JDK / JRE。
-
如果您使用64位版本,请确保您未将JAVA_HOME 设置为一个环境变量。如果设置了此变量,rJava将无法工作,无论什么原因。您可以检查您的JAVA_HOME是否在R中设置:
Sys.getenv(JAVA_HOME)
如果您需要设置JAVA_HOME加载rJava之前,您可以在R-session中使用以下代码停用它:
if(Sys.getenv (JAVA_HOME)!=)
Sys.setenv(JAVA_HOME =)
库(rJava)
这在大多数情况下应该做的。此外,这将修复问题在Win7 64位与R 上使用rJava包。我借用了从 R:rJava包安装失败中取消设置变更变量的想法。
I get an error when I'd like to load rJava. JDK is installed. (I run R on a CentOS VM (cloudera demo vm cdh3u4))
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/2.15/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package/namespace load failed for ‘rJava’
Is there something wrong with LD_LIBRARY_PATH
settings? If yes, how can I fix that?
I need rJava running that to install rhdfs later.
Some more information (if needed):
[cloudera@localhost ~]$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
Getting rJava to work depends heavily on your computers configuration. The following is working at least on a windows platform. You could try and check, if this will help you on your platform, too.
- You have to use the same 32bit or 64bit version for both: R and JDK/JRE. A mixture of this will never work (at least for me).
If you use 64bit version make sure, that you do not set JAVA_HOME as a enviorment variable. If this variable is set, rJava will not work for whatever reason. You can check if your JAVA_HOME is set inside R with:
Sys.getenv("JAVA_HOME")
If you need to have JAVA_HOME set (e.g. you need it for maven or something else), you could deactivate it within your R-session with the following code before loading rJava:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This should do the trick in most cases. Furthermore this will fix issue Using the rJava package on Win7 64 bit with R, too. I borrowed the idea of unsetting the enviorment variable from R: rJava package install failing.
这篇关于加载rJava时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!