Spark-submit 无法检测 pip 中安装的模数

2023-11-29

我有一个 python 代码,它具有以下第 3 方依赖项:

import boto3
from warcio.archiveiterator import ArchiveIterator
from warcio.recordloader import ArchiveLoadFailed
import requests
import botocore
from requests_file import FileAdapter
....

我已经使用安装了依赖项pip,并通过命令确保它已正确安装pip list。然后,当我尝试将作业提交到 Spark 时,收到以下错误:

ImportError: No module named 'boto3'

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:193)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:234)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:152)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:63)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
    at org.apache.spark.api.python.PairwiseRDD.compute(PythonRDD.scala:395)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:96)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:53)
    at org.apache.spark.scheduler.Task.run(Task.scala:108)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:335)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

的问题没有命名的模块不仅发生在“boto3”上,也发生在其他模块上。


我尝试过以下事情:

  1. AddedSparkContext.addPyFile(".zip 文件")
  2. 使用提交火花--py 文件
  3. 重新安装点子
  4. 已确定路径环境变量 export PYTHONPATH=$SPARK_HOME/python/:$PYTHONPATH并安装 pip install py4j
  5. 使用python代替spark-submit

软件信息:

  • Python版本:3.4.3
  • 火花版本:2.2.0
  • 在 EMR-AWS 上运行:Linux 版本 2017.09

做之前spark-submit尝试去python shell并尝试导入模块。 还要检查哪个python shell(检查Python路径)默认打开。

如果您能够在 python shell 中成功导入这些模块(与您尝试使用的 python 版本相同)spark-submit),请检查以下内容:

您以哪种方式提交申请?尝试standalone或者如果在纱线上尝试client模式。 也尝试添加export PYSPARK_PYTHON=(your python path)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spark-submit 无法检测 pip 中安装的模数 的相关文章

随机推荐