Возможно, вам нужно добавить файлы pyspark к пути. Обычно я использую функцию, подобную следующей.
def configure_spark(spark_home=None, pyspark_python=None):
spark_home = spark_home or "/path/to/default/spark/home"
os.environ['SPARK_HOME'] = spark_home
# Add the PySpark directories to the Python path:
sys.path.insert(1, os.path.join(spark_home, 'python'))
sys.path.insert(1, os.path.join(spark_home, 'python', 'pyspark'))
sys.path.insert(1, os.path.join(spark_home, 'python', 'build'))
# If PySpark isn't specified, use currently running Python binary:
pyspark_python = pyspark_python or sys.executable
os.environ['PYSPARK_PYTHON'] = pyspark_python
Затем, вы можете вызвать функцию перед импортом pyspark:
configure_spark('/path/to/spark/home')
from pyspark import SparkContext
Спарк дома на узле ЭМИ должен быть чем-то вроде /home/hadoop/spark
. См. https://aws.amazon.com/articles/Elastic-MapReduce/4926593393724923 для более подробной информации.