Skip to content

pyspark need Py2 to work, graceful and helping fail if system default is Py3 #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions bin/pyspark
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ fi

# Figure out which Python executable to use
if [ -z "$PYSPARK_PYTHON" ] ; then
exit_if_not_python_version(){
_DefaultPythonVersion=`python --version | sed -s 's/[A-Za-z]*\ \([0-9]\)\..*/\1/'`
_RequirePythonVersion=$1

if [[ "$_RequirePythonVersion" != "$_DefaultPythonVersion" ]]; then
echo "Error: Default Python on this machine is Python${_DefaultPythonVersion}, PySpark requires Python2."
_RequirePython=`which python${_RequirePythonVersion} 2>/dev/null`
if [[ "$_RequirePython" == "" ]]; then
echo "You don't have Python2 installed; install it first. Then run 'PYSPARK_PYTHON=<path-to-python2> $0'"
else
echo "Run 'PYSPARK_PYTHON=${_RequirePython} $0'"
fi
exit 1
fi
}

exit_if_not_python_version 2
PYSPARK_PYTHON="python"
fi
export PYSPARK_PYTHON
Expand Down