Skip to content

Commit

Permalink
[python alternative] pyspark require Python2, failing if system defau…
Browse files Browse the repository at this point in the history
…lt is Py3 from shell.py

Python alternative for apache#392; managed from shell.py

Author: AbhishekKr <[email protected]>

Closes apache#399 from abhishekkr/pyspark_shell and squashes the following commits:

134bdc9 [AbhishekKr] pyspark require Python2, failing if system default is Py3 from shell.py
  • Loading branch information
abhishekkr authored and pdeyhim committed Jun 25, 2014
1 parent 664f38d commit 456f88d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions python/pyspark/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
This file is designed to be launched as a PYTHONSTARTUP script.
"""

import sys
if sys.version_info.major != 2:
print("Error: Default Python used is Python%s" % sys.version_info.major)
print("\tSet env variable PYSPARK_PYTHON to Python2 binary and re-run it.")
sys.exit(1)


import os
import platform
import pyspark
Expand All @@ -34,21 +42,21 @@

sc = SparkContext(os.environ.get("MASTER", "local[*]"), "PySparkShell", pyFiles=add_files)

print """Welcome to
print("""Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 1.0.0-SNAPSHOT
/_/
"""
print "Using Python version %s (%s, %s)" % (
""")
print("Using Python version %s (%s, %s)" % (
platform.python_version(),
platform.python_build()[0],
platform.python_build()[1])
print "Spark context available as sc."
platform.python_build()[1]))
print("Spark context available as sc.")

if add_files != None:
print "Adding files: [%s]" % ", ".join(add_files)
print("Adding files: [%s]" % ", ".join(add_files))

# The ./bin/pyspark script stores the old PYTHONSTARTUP value in OLD_PYTHONSTARTUP,
# which allows us to execute the user's PYTHONSTARTUP file:
Expand Down

0 comments on commit 456f88d

Please sign in to comment.