Last active
January 23, 2020 18:11
-
-
Save aneeshpanoli/e094f86f01f037e4dd83f334592d27f8 to your computer and use it in GitHub Desktop.
Steps to setup colab notebook pyspark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import STDOUT, check_call, check_output | |
def install_java_scala(): | |
try: | |
java_ver = check_output(['java', '-version'], stderr=STDOUT) | |
except: | |
java_ver = b'' | |
try: | |
scala_ver = check_output(['scala', '-version'], stderr=STDOUT) | |
except: | |
scala_ver = b'' | |
if b'1.8.0_232' not in java_ver: | |
java_8_install = ['apt-get', '--quiet', 'install', | |
'-y', 'openjdk-8-jdk-headless'] | |
java_set_alt = ['update-alternatives', '--set', 'java', | |
'/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java' ] | |
check_call(java_8_install, stdout=open(os.devnull, 'wb'), | |
stderr=STDOUT) | |
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64" | |
check_call(java_set_alt) | |
if b'2.11.12' not in scala_ver: | |
scala_install = ['apt-get', '--quiet', 'install', 'scala'] | |
check_call(scala_install) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment