簡體   English   中英

如何在 EMR 上安裝軟件包

[英]How to install packages on EMR

我在 AWS 上創建了一個集群,並安裝了 Jupyter 和 python3。 現在我可以在單元格中鍵入代碼,我發現 'numpy' 已安裝,即通過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它給了我一個錯誤

---------------------------------------------------------------------------
ImportError                               
Traceback (most recent call last)<ipython-input-8-af55e7023913> in <module>()----> 1 import pandas as pd

ImportError: No module named 'pandas'

一般來說,我們應該如何在EMR中安裝相關的python包?

在我的筆記本電腦中,在 jupyter 中,我總是執行“!pip install package”並且它有效。 但是為什么它在 EMR 上的 jupyer 中不起作用?

我嘗試使用pip install安裝 python 包,但我得到了pip: command not found 所以我用pip3而不是 pip,它奏效了。

使用 EMR 5.30.1

在 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 文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM