gpt4 book ai didi

java - 如何在 Amazon Linux 上安装 dplyr-snowflakedb 和 rJava?

转载 作者:行者123 更新时间:2023-12-01 11:13:43 26 4
gpt4 key购买 nike

这里的目标是安装 dplyr-snowflakedb R在 AWS Linux 机器上打包。问题在于rJava包不会安装,它失败并显示以下错误消息:

“installation of package ‘rJava’ had non-zero exit status”
dplyr.snowflakedb包提出以下建议:

The rJava package needs to be installed and working with Java 8 to support the SnowflakeDB JDBC requirements. This may require:

  • installing Java 8

  • running R CMD javareconf so R uses the Java 8 for its JAVA_HOME

  • installing rJava from source so it can be linked against Java 8



尽管尝试了这些策略,rJava 仍然无法安装在 AWS linux 上。

AWS linux 实例运行的是 Java 8:
conda activate ~/anaconda3/envs/R
(R) [ec2-user@ip-xx-xx-xx-xx ~]$ java -version

>>> openjdk version "1.8.0_152-release"
>>> OpenJDK Runtime Environment (build 1.8.0_152-release-1056-b12)
>>> OpenJDK 64-Bit Server VM (build 25.152-b12, mixed mode)
R CMD javareconf命令被执行:
Java interpreter : /home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/bin/java
Java version : 1.8.0_152-release
Java home path : /home/ec2-user/anaconda3/envs/JupyterSystemEnv
Java compiler : /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/javac
Java headers gen.: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/javah
Java archive tool: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/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)/jre/lib/amd64/server -ljvm
x86_64-conda_cos6-linux-gnu-cc -I"/home/ec2-user/anaconda3/envs/R/lib/R/include" -DNDEBUG -I/home/ec2-user/anaconda3/envs/JupyterSystemEnv/include -I/home/ec2-user/anaconda3/envs/JupyterSystemEnv/include/linux -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -I/home/ec2-user/anaconda3/envs/R/include -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/ec2-user/anaconda3/envs/R/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/home/ec2-user/anaconda3/envs/R=/usr/local/src/conda-prefix -c conftest.c -o conftest.o
x86_64-conda_cos6-linux-gnu-cc -shared -L/home/ec2-user/anaconda3/envs/R/lib/R/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/ec2-user/anaconda3/envs/R/lib -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -L/home/ec2-user/anaconda3/envs/R/lib -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -o conftest.so conftest.o -L/home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/lib/amd64/server -ljvm -L/home/ec2-user/anaconda3/envs/R/lib/R/lib -lR


JAVA_HOME : /home/ec2-user/anaconda3/envs/JupyterSystemEnv
Java library path: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
Updating Java configuration in /home/ec2-user/anaconda3/envs/R/lib/R
Done.

不清楚如何安装 rJava从源代码或将其链接到 Java 8。

这个相关问题: Can't install rJava on ubuntu system建议运行以下命令:
sudo apt-get install r-cran-rjava

但是 AWS Linux 不使用 apt-get ,它使用 yum , 和 yum 的等效命令找不到包:
sudo yum install r-cran-rjava
>>> No package r-cran-rjava available.

也许问题是 JAVA_HOME 设置为 JupyterSystemEnv而不是 R环境?

最佳答案

  • 确保不仅安装 JRE,还安装 JDK:
    sudo yum install java-1.8.0-openjdksudo yum install java-1.8.0-openjdk-devel
  • 配置:sudo R CMD javareconf
  • 在 R 中安装 rJava:install.packages("rJava")
  • 一旦您安装了 rJava 并验证它使用的是 Java 8,您就可以安装 dplyr 和依赖项。install.packages(c("RJDBC", "DBI", "dplyr"))
  • 安装 dplyr.snowflakedbinstall.packages("devtools")devtools::install_github("snowflakedb/dplyr-snowflakedb")

  • 如果您在安装 devtools 时遇到问题,请尝试安装依赖项或尝试另一个 repo:
  • install.packages("devtools", dependencies=TRUE)
  • install.packages('devtools',dependencies=TRUE,
    repos='https://stat.ethz.ch/CRAN/')
  • 关于java - 如何在 Amazon Linux 上安装 dplyr-snowflakedb 和 rJava?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62300473/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com