Skip to content Skip to sidebar Skip to footer

How Do I Setup Pyspark In Python 3 With Spark-env.sh.template

Because i have this issue in my ipython3 notebook, i guess i have to change 'spark-env.sh.template' somehow. Exception: Python in worker has different version 2.7 than that in driv

Solution 1:

Spark does not yet work with Python 3.If you wish to use the Python API you will also need a Python interpreter (version 2.6 or newer).

I had the same issue when running IPYTHON=1 ./pyspark.

Ok quick fix

Edit vim pyspark and change PYSPARK_DRIVER_PYTHON="ipython" line to

PYSPARK_DRIVER_PYTHON="ipython2"

That's it.

If you want to check where dose ipython points to,

Type which ipython in terminal and I bet that'll be

/Library/Frameworks/Python.framework/Versions/3.4/bin/ipython

**UPDATED**

The latest version of spark works well with python 3. So this may not need with the latest version.

Just set the environment variable:

export PYSPARK_PYTHON=python3

in case you want this change to be permanent add this line to pyspark script

Solution 2:

I believe you can specify the two separately, like so:

PYSPARK_PYTHON=/opt/anaconda/bin/ipython
PYSPARK_DRIVER_PYTHON=/opt/anaconda/bin/ipython

Based on this other question Apache Spark: How to use pyspark with Python 3.

Post a Comment for "How Do I Setup Pyspark In Python 3 With Spark-env.sh.template"