IT story

R : rJava 패키지 설치 실패

hot-time 2020. 8. 7. 07:54
반응형

R : rJava 패키지 설치 실패


install.packages("rJava")명령을 사용하여 rJava를 설치할 때 다음 오류가 발생합니다.

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다음을 반환합니다.

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

오류를 검색 할 때 다른 사람들이 동일한 문제를 겪고 있지만 내가 한 "JRE뿐만 아니라 전체 JDK를 설치"하는 것 외에 다른 해결책을 찾지 못하는 것을 알 수 있습니다.

내가 읽은 또 다른 것은 sudo R CMD javareconf오류없이 매우 행복하게 실행 되는 실행 이었습니다 .

내 문제가 무엇인지 아이디어가 있습니까?

[[편집]] 이 문제가 발생한 지 몇 달이 지났습니다. 아래에 게시 한 답변에 설명 된대로 Java 경로를 편집하여 처음에이 문제를 해결했습니다. 최근에 새로운 Ubuntu 설치에서 동일한 문제가 발생했습니다. apt-get을 사용하여 rJava 패키지를 설치하라는 Dirk의 권장 사항을 시도했습니다. 완벽하게 작동했습니다. 처음에 내가 인식하지 못한 점은 Ubuntu apt-get 메소드를 사용하여 패키지를 설치하는 것이 R 내부에서 install.packages ()를 사용하여 동일한 패키지를로드하는 것과 근본적으로 다르다는 것입니다. Ubuntu 패키지는 내가 깨닫지 못하거나 감사하지 않은 몇 가지 문제를 해결합니다. .


하지 않을

apt-get install r-cran-rjava

더 쉬웠습니까? useR 에서 저에게 물었을 수도 있습니다 ! :)


내 문제는 내 JAVA_HOME환경 변수의 문제였습니다 . 예, 충격적입니다. 내 초기에 설정 PATH하고 JAVA_HOME다음과 같이 보았다 :

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

그리고 /jre이제 다음과 같이 추가 했습니다.

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

Java의 모든 것이 제대로 작동하는 것처럼 보였지만 /jrerJava는 그렇지 않습니다. 이상한.


감사합니다-에 대한 귀하의 제안은 $JAVA_HOME저를 비슷한 해결책으로 안내합니다.

prompt$ unset JAVA_HOME

R을 호출하기 전에.


동일한 문제가 발생했으며 아래 명령을 실행 한 후에 작동했습니다.

export JAVA_LIBS="$JAVA_LIBS -ldl"
R CMD javareconf

http://www-01.ibm.com/support/knowledgecenter/SSPT3X_3.0.0/com.ibm.swg.im.infosphere.biginsights.install.doc/doc/install_install_r.html 에서 세부 사항을 참조하십시오 .


이것은 Ubuntu 12.04 및 R 버전 3.0에서 저에게 효과적이었습니다.

cd /usr/lib/jvm/java-6-sun-1.6.0.26/include

이것은 jni.h가있는 디렉토리입니다.

다음으로 다른 필수 헤더 파일에 대한 소프트 링크를 만듭니다 (아래 JAVA_CPPFLAGS 옵션에 둘 이상의 디렉토리를 포함하는 방법을 찾기에는 너무 게으름) :

sudo ln -s linux/jni_md.h .

드디어

sudo R CMD javareconf JAVA_CPPFLAGS=-I/usr/lib/jvm/java-6-sun-1.6.0.26/include

아래는 다른 게시물에 대한 내 답변 중 하나입니다- 오류 : 지금 설치된 패키지를로드 할 수 없습니다
(이 질문과도 관련이 있습니다).

Linux (Ubuntu) 사용자 : oracle-java (7/8)가 설치되어있는 경우. 이 위치에 /usr/lib/jvm있으며 sudo액세스가 필요합니다.

/etc/ld.so.conf.d/java.conf다음 항목을 사용 하여 파일 만듭니다 .

/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server

(Java 버전에 따라 java-8-oracle을 java-7-oracle로 대체하십시오)

그때:

sudo ldconfig

RStudio를 다시 시작한 다음 rJava 패키지를 설치합니다.


그것이 내가 작동하는 방법입니다.

Linux (Ubuntu 16.04)

sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo R CMD javareconf

R에서 :

install.packages("rJava")

AMD64의 Gentoo에서 R을 실행합니다. R 2.12.0으로 업그레이드했습니다.

R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) and those pesky messages went away.

Jan Vandermeer


I tried to install openjdk-7-* but still I had problems installing rJava. Turns out after I restarted my computer, then there was no problem at all.

so

sudo apt-get install openjdk-7-*


RESTART after installing java, then try to install package "rJava" in R

The rJava package looks for the /usr/lib/jvm/default-java/ folder. But it's not available as default. This folder have a symlink for the default java configured for the system.

To activate the default java install the following packages:

sudo apt-get install default-jre default-jre-headless

Tested on ubuntu 17.04 with CRAN R 3.4.1


What worked for me was changing JAVA_HOME from file /usr/lib/R/etc/javaconf

I first checked what was my version of Java enabled : sudo update-alternatives --config java. In my case, it was java-8-oracle

I opened the file /usr/lib/R/etc/javaconf and replaced default-java by java-8-oracle :

${JAVA_HOME=/usr/lib/jvm/default-java}

replaced by :

${JAVA_HOME=/usr/lib/jvm/java-8-oracle}

And then sudo R CMD javareconf

I restarted RStudio, and could then install rJava.


what I do is here:

  1. in /etc/apt/sources.list, add:

    deb http://ftp.de.debian.org/debian sid main

Note:the rjava should be latest version

2 run: sudo apt-get update sudo apt-get install r-cran-rjava

Once update the old version of rjava, then can install rhdfs_1.0.8.


I got it working by downloading : https://cran.r-project.org/src/contrib/rJava_0.9-8.tar.gz and running command R CMD install rJava_0.9-8.tar.gz


The problem was rJava wont install in RStudio (Version 1.0.136). The following worked for me (macOS Sierra version 10.12.6) (found here):

Step-1: Download and install javaforosx.dmg from here

Step-2: Next, run the command from inside RStudio:

install.packages("rJava", type = 'source')

I was facing the same problem while using Windows 10. I have solved the problem using the following procedure

  1. Download Java from https://java.com/en/download/windows-64bit.jsp for 64-bit windows\Install it
  2. Download Java development kit from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html for 64-bit windows\Install it
  3. Then right click on “This PC” icon in desktop\Properties\Advanced system settings\Advanced\Environment Variables\Under System variables select Path\Click Edit\Click on New\Copy and paste paths “C:\Program Files\Java\jdk1.8.0_201\bin” and “C:\Program Files\Java\jre1.8.0_201\bin” (without quote) \OK\OK\OK

Note: jdk1.8.0_201 and jre1.8.0_201 will be changed depending on the version of Java development kit and Java

  1. In Environment Variables window go to User variables for User\Click on New\Put Variable name as “JAVA_HOME” and Variable value as “C:\Program Files\Java\jdk1.8.0_201\bin”\Press OK

To check the installation, open CMD\Type javac\Press Enter and Type java\press enter It will show enter image description here

In RStudio run

Sys.setenv(JAVA_HOME="C:\\Program Files\\Java\\jdk1.8.0_201")

Note: jdk1.8.0_201 will be changed depending on the version of Java development kit

Now you can install and load rJava package without any problem.


I've encountered similar problem on Ubuntu 16.04 and was able to solve it by creating a folder named "default-java" in /usr/lib/jvm and copying into it all the contents of the /usr/lib/jvm/java-8-oracle. I opted for this solution as correcting JAVA_HOME environment variable turned out to be of no use.

참고URL : https://stackoverflow.com/questions/3311940/r-rjava-package-install-failing

반응형