Automatically Install OpenJDK into SageMaker Notebook

Viewed 665

I have the following lines of code

import tabula
tabula.environment_info()

This results in the following error:

    Python version:
    3.7.10 (default, Jun  4 2021, 14:48:32) 
[GCC 7.5.0]
Java version:
    `java -version` faild. `java` command is not found from this Pythonprocess. Please ensure Java is installed and PATH is set for `java`
tabula-py version: 2.3.0
platform: Linux-4.14.243-185.433.amzn2.x86_64-x86_64-with-debian-10.6
uname:
    uname_result(system='Linux', node='datascience-1-0-ml-t3-medium-1abf3407f667f989be9d86559395', release='4.14.243-185.433.amzn2.x86_64', version='#1 SMP Mon Aug 9 05:55:52 UTC 2021', machine='x86_64', processor='')
linux_distribution: ('Debian GNU/Linux', '10', 'buster')
mac_ver: ('', ('', '', ''), '')

I am trying to figure out how to set up the appropriate cmd line statement to install OpenJDK from the SageMaker Notebook environment.

I have opened up the terminal and inserted the following line of code and am still seeing the above error.

pip install install-jdk -t.

Overall, Before installing tabula-py, I need to ensure that I have Java runtime on my environment. How can I facilitate this in SageMaker?

1 Answers

You can use a Lifecycle Configuration Script to automatically install the OpenJDK package on creation or startup of a new notebook. There's a very similar example here from the AWS public script repo.

Related