I installed Spark, ran the sbt assembly, and can open bin/pyspark with no problem. However, I am running into problems loading the pyspark module into ipython. I'm getting the following error:
In [1]: import pyspark
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c15ae3402d12> in <module>()
----> 1 import pyspark
/usr/local/spark/python/pyspark/__init__.py in <module>()
61
62 from pyspark.conf import SparkConf
---> 63 from pyspark.context import SparkContext
64 from pyspark.sql import SQLContext
65 from pyspark.rdd import RDD
/usr/local/spark/python/pyspark/context.py in <module>()
28 from pyspark.conf import SparkConf
29 from pyspark.files import SparkFiles
---> 30 from pyspark.java_gateway import launch_gateway
31 from pyspark.serializers import PickleSerializer, BatchedSerializer, UTF8Deserializer, \
32 PairDeserializer, CompressedSerializer
/usr/local/spark/python/pyspark/java_gateway.py in <module>()
24 from subprocess import Popen, PIPE
25 from threading import Thread
---> 26 from py4j.java_gateway import java_import, JavaGateway, GatewayClient
27
28
ImportError: No module named py4j.java_gateway
sudo pip install py4j
fixed this problem for me. I assume this error comes after you already added SPARK_HOME to the PYTHON_PATH? – BanneretPYTHONPATH
to point to all needed python dependencies but got the same error. To resolve the problem, I also had to 1) install another copy of py4j at thesite-packages
folder where usual python packages are installed 2) change the permission of everything in the py4j folder so YARN executor nodes can read / execute the relevant files. – Betelgeuse