Thursday, May 11, 2017

ImportError: No module named pyspark

When you import "pyspark", you might get the following error:

>>> import pyspark
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyspark
>>>

Install Spark first if it hasn't been installed yet.

Add the following to your ".bash_profile":

SPARK_HOME=/Users/izeye/Applications/spark-2.1.1-bin-hadoop2.7

export PYTHONPATH="${SPARK_HOME}/python/:$PYTHONPATH"
export PYTHONPATH="${SPARK_HOME}/python/lib/py4j-0.10.4-src.zip:$PYTHONPATH"

Now, it's working as follows:

>>> import pyspark
>>>

No comments:

Post a Comment