web-dev-qa-db-fra.com

R-Project: échec de l'installation du package xlsx (en raison de problèmes de Java)

J'essayais d'installer le paquet xlsx; malheureusement, il existe un problème avec Java que je ne parviens pas à résoudre.

Veuillez trouver ci-dessous la sortie produite lors de la tentative d’installation du paquet xlsx. 

Voici la sortie:


R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("xlsx")
Installing package into ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
also installing the dependencies ‘rJava’, ‘xlsxjars’

trying URL 'contrib/rJava_0.9-6.tar.gz'
Content type 'application/x-gzip' length 567515 bytes (554 Kb)
opened URL
==================================================
downloaded 554 Kb

trying URL 'contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 Mb)
opened URL
==================================================
downloaded 9.0 Mb

trying URL 'contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 Kb)
opened URL
==================================================
downloaded 305 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -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 -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/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 -m64 -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 : '/bin/Java'
archiver    : '/bin/jar'
compiler    : '/bin/javac'
header prep.: '/bin/javah'
cpp flags   : '-I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux'
Java libs   : '-L/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/AMD64/server -ljvm'
checking whether Java run-time works... 
Error: Could not find or load main class getsp
no
configure: error: Java interpreter '/bin/Java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status
ERROR: dependency ‘rJava’ is not available for package ‘xlsxjars’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/xlsxjars’
Warning in install.packages :
  installation of package ‘xlsxjars’ had non-zero exit status
ERROR: dependencies ‘rJava’, ‘xlsxjars’ are not available for package ‘xlsx’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/xlsx’
Warning in install.packages :
  installation of package ‘xlsx’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpj1UG8a/downloaded_packages’

Java est installé:

La version Java donne la sortie suivante:

Java version "1.7.0_71"
OpenJDK Runtime Environment (Fedora-2.5.3.0.fc20-x86_64 u71-b14)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

"Sudo R CMD javareconf" mène à:

Java interpreter : /bin/Java
Java version     : 1.7.0_71
Java home path   : /usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre
Java compiler    : /bin/javac
Java headers gen.: /bin/javah
Java archive tool: /bin/jar

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(Java_HOME)/../include -I$(Java_HOME)/../include/linux
detected JNI linker flags : -L$(Java_HOME)/lib/AMD64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic  -c conftest.c -o conftest.o
gcc -m64 -std=gnu99 -shared -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/AMD64/server -ljvm -L/usr/lib64/R/lib -lR


Java_HOME        : /usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre
Java library path: $(Java_HOME)/lib/AMD64/server
JNI cpp flags    : -I$(Java_HOME)/../include -I$(Java_HOME)/../include/linux
JNI linker flags : -L$(Java_HOME)/lib/AMD64/server -ljvm
Updating Java configuration in /usr/lib64/R
Done.

Néanmoins, install.packages ('rJava') conduit à:

checking Java support in R... present:
interpreter : '/bin/Java'
archiver    : '/bin/jar'
compiler    : '/bin/javac'
header prep.: '/bin/javah'
cpp flags   : '-I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux'
Java libs   : '-L/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/AMD64/server -ljvm'
checking whether Java run-time works... 
Error: Could not find or load main class getsp
no
configure: error: Java interpreter '/bin/Java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpnl17m7/downloaded_packages’

Je ne sais pas comment résoudre ce problème de Java. Je travaille avec RStudio et Fedora . Votre aide est très appréciée.

Merci

Tamas

10
tamasp

Si vous avez installé Java, essayez de réinitialiser la configuration Java de R à partir de la ligne de commande.

Sudo R CMD javareconf

Ensuite, essayez à nouveau d'installer rJava (vous pouvez d'abord redémarrer RStudio)

install.packages('rJava')

Si cela ne résout toujours pas votre problème, l'erreur indique que R ne peut pas charger getsp.

checking whether Java run-time works... 
Error: Could not find or load main class getsp

Tout d'abord, vérifiez que getsp est accessible.

locate getsp

La sortie peut contenir plusieurs éléments, mais vous devriez trouver quelque chose comme ceci:

/usr/share/R/share/Java/getsp.class

Ensuite, nous voulons que cela soit accessible afin de l'exporter afin que R puisse le trouver:

export CLASSPATH=/usr/share/R/share/Java

Dans la même fenêtre, démarrez une autre session R et essayez d’installer rJava à nouveau.

Une autre chose à faire serait Java_HOME et relancez la javareconf

export Java_HOME=/usr/lib/jvm/Java-1.7.0-openjdk-1.7.0.71.x86_64/jre
export PATH=$PATH:$Java_HOME/bin
Sudo R CMD javareconf

Il est également recommandé de unset CLASSPATH dans les problèmes de rJava car cela pourrait entraîner d'autres problèmes sur la ligne. Vous devriez probablement le faire avant d'essayer de changer Java_HOME et de le réinitialiser si cela ne résout toujours pas le problème.

MODIFIER

Étant donné que cette question est restée «sans réponse» pendant un bon bout de temps, j'ai pensé que je devrais aussi ajouter ma recommandation d'utiliser simplement le paquet readxl qui n'utilise pas Java. Il s'installe beaucoup plus facilement et fait partie de la tidyverse. Juste une recommandation générale pour ceux qui essaient de travailler avec des fichiers Excel.

13
cdeterman

D'accord, j'ai finalement réussi à le gérer en ajoutant "Java_HOME =/usr/lib/jvm/Java-1.8.0-openjdk-1.8.0.25.x86_64/jre /" à .bashrc dans mon dossier personnel.

Merci pour votre aide, cdeterman.

Meilleur Tamas

3
tamasp

C'est le problème de Java. Je pense que vous n'avez pas installé Java sur votre système. Vérifiez si Java est déjà installé:

Java -version

S'il renvoie "Le programme Java peut être trouvé dans les packages suivants", Java n'a pas encore été installé. Exécutez donc la commande suivante:

Sudo apt-get install default-jre
Sudo apt-get install default-jdk

Ensuite, essayez de réinstaller le package.

0
Che