Skip to content

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

2 minute read
0

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

Resolution

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

  1. Open the SageMaker AI console.

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

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

  4. Choose Open JupyterLab.

  5. Confirm that the notebook can connect to the internet so that you can download the rJDBC package from the Anaconda repository.
    Note: To install the package without internet access, see Private package installation in Amazon SageMaker AI running in internet-free mode.

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

    source activate R
    conda install -y -c r r-rjdbc
    conda deactivate
  7. Open a new Jupyter notebook with the R kernel.

  8. Run the following command in a cell:

    dyn.load('/home/ec2-user/anaconda3/envs/R/lib/jvm/lib/server/libjvm.so')
  9. To confirm that you installed the rJDBC package, run the following command in the Jupyter notebook:

    library(RJDBC)

    The output must look similar to the following example:

    Loading required package: DBI
    Loading required package: rJava
  10. To make the rJDBC package persist even after you restart the notebook instance, create a custom persistent Conda installation on your notebook instance's volume.

Related information

Access notebook instances

External library and kernel installation

How do I install Python packages in a conda environment on a SageMaker AI notebook instance?

AWS OFFICIALUpdated 8 months ago