在R中安装RWeka的问题(Ubuntu 16.04)

时间:2017-08-23 12:18:21

标签: java r ubuntu rweka

我想安装需要RWeka的Fselector软件包,但是在安装RWeka时它会跟踪错误:

Error : .onLoad failed in loadNamespace() for 'RWeka', details:
call: .jcall("java/lang/System", "V", "setOut", out)
error: method setOut with signature (Ljava/io/PrintStream;)V not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/gaurav/R/x86_64-pc-linux-gnu-library/3.3/RWeka’
Warning in install.packages :
installation of package ‘RWeka’ had non-zero exit status
ERROR: dependency ‘RWeka’ is not available for package ‘FSelector’
* removing ‘/home/gaurav/R/x86_64-pc-linux-gnu-library/3.3/FSelector’
Warning in install.packages :
installation of package ‘FSelector’ had non-zero exit status

我搜索了相同内容并使用jdk进行了一些修改,更新了bashrc中jdk / bin的路径,但没有任何效果。

Session Info

R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

locale:
[1] LC_CTYPE=en_IN.UTF-8       LC_NUMERIC=C   LC_TIME=en_IN.UTF-8       
[4] LC_COLLATE=en_IN.UTF-8     LC_MONETARY=en_IN.UTF-8   LC_MESSAGES=en_IN.UTF-8   
[7] LC_PAPER=en_IN.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] Rcpp_0.12.12     digest_0.6.12    mime_0.5         grid_3.3.3       plyr_1.8.4      
[6] R6_2.2.2         xtable_1.8-2     gtable_0.2.0     scales_0.4.1     ggplot2_2.2.1   
[11] rlang_0.1.1      lazyeval_0.2.0   brew_1.0-6       tools_3.3.3      munsell_0.4.3   
[16] Rook_1.1-1       shiny_1.0.4      httpuv_1.3.5     colorspace_1.3-2 htmltools_0.3.6 
[21] tibble_1.3.3    

任何人都可以帮助我。

提前致谢

更新1:@Nanov,我按照步骤但仍然收到同样的错误,我有openjdk 8并更新了bashrc中的路径,&当我使用" sudo R CMD javareconf"我得到以下信息:

gaurav@gaurav-ds:~$ sudo R CMD javareconf
Java interpreter : /usr/lib/jvm/java-8-oracle/jre/bin/java
Java version     : 1.8.0_131
Java home path   : /usr/lib/jvm/java-8-oracle/jre
Java compiler    : not present
Java headers gen.:
Java archive tool:

trying to compile and link a JNI program 
detected JNI cpp flags    : 
detected JNI linker flags : -L/usr/lib -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time-D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.oconftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
             ^
compilation terminated.
/usr/lib/R/etc/Makeconf:132: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program.
JAVA_HOME        : /usr/lib/jvm/java-8-oracle/jre
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /usr/lib/R
Done.

1 个答案:

答案 0 :(得分:3)

 sudo apt-get install r-cran-rjava
 sudo apt-get install openjdk-8-jdk
 sudo rm -rf /usr/lib/jvm/default-java
 sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/default-java
 sudo R CMD javareconf

 sudo R
 install.packages(“RWeka”)

最好安装openjdk-8-jdk,因为在最新版本-9-是bug。