安裝 rJava 和 RJDBC 程式庫Install rJava and RJDBC libraries
本文說明如何安裝 rJAVA 和 RJBDC 程式庫。This article explains how to install rJava and RJBDC libraries.
問題Problem
當您使用筆記本資料格中的下列命令來安裝 rJAVA 和 RJDBC 程式庫時:When you install rJava and RJDBC libraries with the following command in a notebook cell:
install.packages(c("rJava", "RJDBC"))
您會發現下列錯誤:You observe the following error:
ERROR: configuration failed for package 'rJava'
原因Cause
RJAVA 和 RJDBC 套件會檢查 Azure Databricks R 目錄中不存在的 JAVA 相依性和檔案路徑。The rJava and RJDBC packages check for Java dependencies and file paths that are not present in the Azure Databricks R directory.
解決方法Solution
請遵循下列步驟,在執行中的叢集上安裝這些程式庫。Follow the steps below to install these libraries on running clusters.
在儲存格中執行下列命令
%sh
。Run following commands in a%sh
cell.%sh ls -l /usr/bin/java ls -l /etc/alternatives/java ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/default-java R CMD javareconf
安裝 rJAVA 和 RJDBC 套件。Install the rJava and RJDBC packages.
install.packages(c("rJava", "RJDBC"))
確認已安裝 rJAVA 套件。Verify that the rJava package is installed.
dyn.load('/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so') library(rJava)