Spark-submit AWS EMR和安装了Anaconda的python库

问题描述 投票:0回答:1

我从单独的ec2实例中使用boto3启动EMR群集,并使用如下所示的引导脚本:

#!/bin/bash
############################################################################
#For all nodes including master                              #########
############################################################################

wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
bash Anaconda3-2019.10-Linux-x86_64.sh -b -p /mnt1/anaconda3

export PATH=/mnt1/anaconda3/bin:$PATH
echo "export PATH="/mnt1/anaconda3/bin:$PATH"" >> ~/.bash_profile

sudo sed -i -e '$a\export PYSPARK_PYTHON=/mnt1/anaconda3/bin/python' /etc/spark/conf/spark-env.sh
echo "export PYSPARK_PYTHON="/mnt1/anaconda3/bin/python3"" >> ~/.bash_profile

conda install -c conda-forge -y shap
conda install -c conda-forge -y lightgbm
conda install -c anaconda -y numpy
conda install -c anaconda -y pandas
conda install -c conda-forge -y pyarrow
conda install -c anaconda -y boto3

############################################################################
#For master                                                #########
############################################################################

if [ `grep 'isMaster' /mnt/var/lib/info/instance.json | awk -F ':' '{print $2}' | awk -F ',' '{print $1}'` = 'true' ]; then

sudo sed -i -e '$a\export PYSPARK_PYTHON=/mnt1/anaconda3/bin/python' /etc/spark/conf/spark-env.sh

echo "export PYSPARK_PYTHON="/mnt1/anaconda3/bin/python3"" >> ~/.bash_profile

sudo yum -y install git-core

conda install -c conda-forge -y jupyterlab
conda install -y jupyter
conda install -c conda-forge -y s3fs
conda install -c conda-forge -y nodejs

pip install spark-df-profiling


jupyter labextension install jupyterlab_filetree
jupyter labextension install @jupyterlab/toc

fi

然后我使用add_job_flow_steps以编程方式将步骤添加到正在运行的集群中>

action = conn.add_job_flow_steps(JobFlowId=curr_cluster_id, Steps=layer_function_steps)

该步骤是形成完美的火花提交。

在导入的python文件之一中,我导入了boto3。我得到的错误是

ImportError: No module named boto3

很明显,我正在安装此库。如果我通过SSH进入主节点并运行

python
import boto3

它工作正常。自从我执行conda安装以来,使用已安装的库的spark-submit会出现某种问题吗?

我从一个单独的ec2实例中使用boto3启动一个EMR群集,并使用如下所示的引导脚本:#!/ bin / bash #################### ################################################ #...

pyspark boto3 amazon-emr spark-submit
1个回答
0
投票

AWS有一个有助于启动EMR的项目(AWS Data Wrangler)。>>

此代码段应该可以在启用Python 3的情况下启动您的集群:

© www.soinside.com 2019 - 2024. All rights reserved.