Skip to content

Instantly share code, notes, and snippets.

@BryanCutler
Last active July 29, 2022 01:06

Revisions

  1. BryanCutler revised this gist Jul 31, 2019. No changes.
  2. BryanCutler revised this gist Jul 31, 2019. No changes.
  3. BryanCutler created this gist Jul 10, 2019.
    35 changes: 35 additions & 0 deletions start_jupyter_pyspark.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env bash

    #
    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements. See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License. You may obtain a copy of the License at
    #
    # http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    #

    # Starts a Jupyter Notebook Server with a PySpark Kernel.
    # to run, SPARK_HOME must be set and point to a Spark installation
    # or run from the Spark installation directory.

    # Alternatively, as a single command instead of the script:
    # $ PYSPARK_DRIVER_PYTHON=jupyter PYSPARK_DRIVER_PYTHON_OPTS='notebook' $SPARK_HOME/bin/pyspark

    # Use current directory if SPARK_HOME not set
    if [ -z "${SPARK_HOME}" ]; then
    export SPARK_HOME="$(dirname "$0")"
    fi

    export PYSPARK_DRIVER_PYTHON=jupyter
    export PYSPARK_DRIVER_PYTHON_OPTS='notebook'

    exec "${SPARK_HOME}"/bin/pyspark "$@"