为什么在 python 控制台中对 SparkSession.builder.getOrCreate() 的调用被视为命令行 Spark-submit?

2024-05-03

代替python console我正在尝试创建一个Spark Session(我没有使用pyspark以隔离依赖关系)。为什么是spark-submit命令行提示并生成错误?

NOTE: SPARK_PREPEND_CLASSES is set, placing locally compiled Spark classes ahead of assembly.
Error: Missing application resource.

NOTE: SPARK_PREPEND_CLASSES is set, placing locally compiled Spark classes ahead of assembly.
Usage: spark-submit [options] <app jar | python file | R file> [app arguments]
Usage: spark-submit --kill [submission ID] --master [spark://...]
..

Options:
  --master MASTER_URL         spark://host:port, mesos://host:port, yarn,
                              k8s://https://host:port, or local (Default: local[*]).
  --deploy-mode DEPLOY_MODE   Whether to launch the driver program locally ("client") or
                              on one of the worker machines inside the cluster ("cluster")
                              (Default: client).
  --class CLASS_NAME          Your application's main class (for Java / Scala apps).
  --name NAME                 A name of your application.
  --jars JARS                 Comma-separated list of jars to include on the driver
   ..
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in getSpark
  File "/shared/spark/python/pyspark/sql/session.py", line 173, in getOrCreate
    sc = SparkContext.getOrCreate(sparkConf)
  File "/shared/spark/python/pyspark/context.py", line 367, in getOrCreate
    SparkContext(conf=conf or SparkConf())
  File "/shared/spark/python/pyspark/context.py", line 133, in __init__
    SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
  File "/shared/spark/python/pyspark/context.py", line 316, in _ensure_initialized
    SparkContext._gateway = gateway or launch_gateway(conf)
  File "/shared/spark/python/pyspark/java_gateway.py", line 46, in launch_gateway
    return _launch_gateway(conf)
  File "/shared/spark/python/pyspark/java_gateway.py", line 108, in _launch_gateway
    raise Exception("Java gateway process exited before sending its port number")
Exception: Java gateway process exited before sending its port number

在尝试了超过十五种资源之后 - 并仔细阅读了大约两倍的资源 - 唯一有效的就是这个先前未投票的答案https://stackoverflow.com/a/55326797/1056563 https://stackoverflow.com/a/55326797/1056563:

export PYSPARK_SUBMIT_ARGS="--master local[2] pyspark-shell"

是否使用并不重要local[2] or local or local[*]: what is所需的是format包括关键的pyspark-shell piece.

处理这个问题的另一种方法 - 并且更能抵抗环境变化 - 是在您的计算机中方便地使用以下行python code:

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

为什么在 python 控制台中对 SparkSession.builder.getOrCreate() 的调用被视为命令行 Spark-submit? 的相关文章

随机推荐