【问题标题】:Install more Python package/library to each cluster after creating an AWS EMR创建 AWS EMR 后,为每个集群安装更多 Python 包/库
【发布时间】:2020-09-09 06:39:27
【问题描述】:

我最近在 JupyterHub 上将 Spark 与 PySpark 一起使用。我知道在创建 EMR 之前,我可以设置引导程序以在每个集群中设置环境,例如 Python 包/库。但是如果我已经启动了 EMR,如何在不重启 EMR 的情况下安装更多 Python 包/库?

我搜索并得到了一些答案,我可以通过 Jupyterhub 中的单元安装它。例如,

%%spark
sc.install_pypi_package("matplotlib")

我试过了,但出错了

RuntimeError: install_pypi_packages can only use called when spark.pyspark.virtualenv.enabled is set to true

所以我尝试通过将此行添加到该文件中来在主集群上的/usr/lib/spark/conf/spark-defaults.conf 中设置该配置。

"spark.pyspark.virtualenv.enabled": "true"

但是不行,JupyterHub 还是返回错误。

所以我想知道

  1. 如果我想在已启动 EMR 的情况下将更多 Python 包/库安装到集群中,最佳做法是什么?

  2. 如何配置 "spark.pyspark.virtualenv.enabled": "true" 或者我可以在创建 EMR 之前在软件设置中进行设置吗?

提前谢谢你。

【问题讨论】:

  • 我认为如果要在集群中的所有机器上安装它,正确的方法是让管理员将包添加为引导操作:docs.aws.amazon.com/emr/latest/ManagementGuide/…
  • @chappers 这对我来说很清楚,非常感谢!
  • 我在与 EMR 集群实例关联的 SparkMagic(PySpark) 内核上看到了同样的错误。

标签: apache-spark pyspark amazon-emr jupyterhub


【解决方案1】:

我遇到了同样的问题。这是我必须在 sc.install_pypi_package() 调用上方插入的新块。

%%configure -f
{
    "conf": {
        [other configs relevant to your situation],
        "spark.pyspark.python": "python3",
        "spark.pyspark.virtualenv.enabled": "true",
        "spark.pyspark.virtualenv.type":"native",
        "spark.pyspark.virtualenv.bin.path":"/usr/bin/virtualenv"
    }
}

灵感来自https://aws.amazon.com/blogs/big-data/install-python-libraries-on-a-running-cluster-with-emr-notebooks/

【讨论】:

    猜你喜欢
    • 2022-10-14
    • 1970-01-01
    • 2023-02-20
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    相关资源
    最近更新 更多