如何在EMR上安装软件包

时间:2017-04-13 23:48:34

标签: python amazon-web-services emr amazon-emr

我在AWS上创建了一个集群,并安装了Jupyter,python3。现在我可以在单元格中键入代码,然后我发现了“numpy”#39;安装,即"background": {"scripts": ["Alarm.js"], "persistent": false}, ,我能够访问此包中的功能。但是,我发现import numpy as np不存在。所以在下一个单元格中输入pandas,然后显示

!pip install pandas

我认为它已成功安装,但是在下一个单元格中,我输入Requirement already satisfied: pandas in /mnt/usrmoved/local/lib64/python2.7/site-packages Requirement already satisfied: pytz>=2011k in /mnt/usrmoved/local/lib/python2.7/site-packages (from pandas) Requirement already satisfied: numpy>=1.7.0 in /mnt/usrmoved/local/lib64/python2.7/site-packages (from pandas) Requirement already satisfied: python-dateutil in /mnt/usrmoved/local/lib/python2.7/site-packages (from pandas) Requirement already satisfied: six>=1.5 in /mnt/usrmoved/local/lib/python2.7/site-packages (from python-dateutil->pandas) 它会给我一个错误

import pandas as pd

一般来说,我们应该如何在EMR中安装相关的python包?

在我的笔记本电脑中,在jupyter中,我总是这样做#34;! pip install package"它的工作原理。但是为什么它在EMR上的jupyer中不起作用?

2 个答案:

答案 0 :(得分:1)

我尝试使用pip install安装python软件包,但得到pip: command not found。所以我用pip3代替了pip,它起作用了。

使用EMR 5.30.1

答案 1 :(得分:0)

在EMR上安装python软件包的常规方法是使用引导操作指定创建集群时所需的软件包。

此方法可确保将软件包安装在所有节点上,而不仅仅是驱动程序上。

aws emr create-cluster \
--name 'test python packages' \
--release-label emr-5.20.0 \
--region us-east-1 \
--use-default-roles
--instance-type m4.large \
--instance-count 2 \
--bootstrap-actions \
    Path="s3://your-bucket/python-modules.sh",Name='Install Python Modules' \

python-modules.sh将包含用于安装python软件包的命令。例如:

#!/bin/sh

# Install needed packages
sudo pip install pandas

AWS documentation