Ubuntu 18.04의 R 3.6.1에 rJava를 설치하려고 합니다. 비슷한 질문을 검색했지만 제공된 답변이 저에게 도움이 되지 않은 것 같습니다.
나는 처음에 시도했다 sudo apt install r-cran-rjava
.install.packages("rJava")
sudo apt install r-cran-rjava
etc/apt/sources.list
다음에서 제공된 지침에 따라 Debian Buster 저장소를 추가하면 해결되는 것처럼 보이는 종속성 문제가 반환되었습니다 .https://cran.r-project.org/bin/linux/debian/. 이제 r-cran-rjava가 올바르게 설치된 것으로 나타납니다.
$ sudo apt install r-cran-rjava
[sudo] password for tj:
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-cran-rjava is already the newest version (0.9-11-1cran1ppabionic0).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
그러나 R에서 실행하면 install.packages("rJava")
다음과 같은 오류 메시지가 반환됩니다.
install.packages("rJava")
Installing package into ‘/home/tj/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rJava_0.9-11.tar.gz'
Content type 'application/x-gzip' length 675188 bytes (659 KB)
==================================================
downloaded 659 KB
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
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-11-oracle/include -I/usr/lib/jvm/java-11-oracle/include/linux'
java libs : '-L/usr/lib/jvm/java-11-oracle/lib/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether -Xrs will be used... yes
checking whether JNI programs can be compiled... yes
checking whether JNI programs run... configure: error: Unable to run a simple JNI program. Make sure you have configured R with Java support (see R documentation) and check config.log for failure reason.
Warning in system(cmd) : error in running command
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tj/R/x86_64-pc-linux-gnu-library/3.6/rJava’
The downloaded source packages are in
‘/tmp/Rtmp9GstQE/downloaded_packages’
Warning message:
In install.packages("rJava") :
installation of package ‘rJava’ had non-zero exit status
여기에 게시된 지침https://thishosting.rocks/install-java-ubuntu/java-11-oracle을 포함하여 여러 버전의 Java를 설치하도록 안내합니다. sudo update-alternatives --config java
JAVA_HOME을 업데이트하기 전에 java-11-oracle을 기본값으로 설정하고 다음을 제공 sudo nano /etc/environment
합니다 echo $JAVA_HOME
.
$ echo $JAVA_HOME
/usr/lib/jvm/java-11-oracle/bin/java
그러나 내가 실행했을 때 다음과 같이 sudo R CMD javareconf
반환되었습니다.
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version : 11.0.4
Java home path : /usr/lib/jvm/java-11-oracle
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-11-oracle/include -I/usr/lib/jvm/java-11-oracle/include/linux -fpic -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-11-oracle/lib/server -ljvm -L/usr/lib/R/lib -lR
JAVA_HOME : /usr/lib/jvm/java-11-oracle
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
install.packages("rJava")
이전과 동일한 오류 메시지를 반환합니다 . 동일한 방법을 사용하여 java-11-openjdk 및 java-8-openjdk를 기본값으로 설정하려고 시도했으며 주제에 대한 일부 이전 게시물에서 제안한 대로 JAVA_HOME 경로의 여러 변형을 사용해 보았습니다(https://stackoverflow.com/questions/3311940/r-rjava-package-install-failing& https://stackoverflow.com/questions/31684236/java-home-not-working-in-ubuntuR CMD javareconf
) 그러나 지금까지는 install.packages("rjava")
비슷한 결과를 반환하고 있습니다.
저는 R과 Ubuntu를 처음 접했고 이 문제에서 막다른 골목에 도달한 것 같습니다. 누구든지 제가 놓친 부분을 볼 수 있습니까? 이전 버전의 R로 되돌려야 하나요? 어떤 도움이라도 대단히 감사하겠습니다.