How do I install the rJDBC package in the R environment of my Amazon SageMaker notebook instance?

2 minute read
0

I want to install the rJDBC package in the R environment of my Amazon SageMaker notebook instance.

Resolution

To install the rJDBC package in the R environment of your SageMaker notebook instance, do the following:

1.    Open the SageMaker console.

2.    In the navigation pane, choose Notebook, and then choose Notebook instances.

3.    Choose the notebook instance where you want to install the rJDBC package.

4.    Choose Open JupyterLab. Be sure that the notebook can connect to the internet. This connection is required so that you can download the rJDBC package from the Anaconda repository.

5.    Open a new terminal and run the following commands in the given sequence:

source activate R
conda install -y -c r r-rjdbc
conda deactivate

6.    Open a new Jupyter notebook with the R kernel.

7.    Run the following command in a cell:

dyn.load('/home/ec2-user/anaconda3/envs/R/lib/jvm/lib/server/libjvm.so')

8.    To confirm that the rJDBC package is installed, run the following command in the Jupyter notebook:

library(RJDBC)

The output must look similar to the following:

Loading required package: DBI

Loading required package: rJava

Related information

Access notebook instances

Install external libraries and kernels in notebook instances

AWS OFFICIAL
AWS OFFICIALUpdated a year ago