Pyspark, programmatic spark initialization: IllegalArgumentException: missing application resource

When creating a spark context in Python, I get the following error.

 app_name="my_app"
 master="local[*]"
 sc = SparkContext(appName=app_name, master=master)

Exception in thread "main" java.lang.IllegalArgumentException: Missing application resource.
at org.apache.spark.launcher.CommandBuilderUtils.checkArgument(CommandBuilderUtils.java:241)
at org.apache.spark.launcher.SparkSubmitCommandBuilder.buildSparkSubmitArgs(SparkSubmitCommandBuilder.java:160)
at org.apache.spark.launcher.SparkSubmitCommandBuilder.buildSparkSubmitCommand(SparkSubmitCommandBuilder.java:276)
at org.apache.spark.launcher.SparkSubmitCommandBuilder.buildCommand(SparkSubmitCommandBuilder.java:151)
at org.apache.spark.launcher.Main.main(Main.java:86)

....

pyspark.zip/pyspark/java_gateway.py", line 94, in launch_gateway
raise Exception("Java gateway process exited before sending the driver its port number")
Exception: Java gateway process exited before sending the driver its port number

It seems to launch a spark trigger.

+6
source share
1 answer

This was due to existing env variables that were in conflict. I deleted them in a Python program and now it works without crashing.

eg:

import  os
#check if pyspark env vars are set and then reset to required or delete.   
del os.environ['PYSPARK_SUBMIT_ARGS']

The correct solution is to remove it in .bashrc or .zshrc or in any other env initialization scripts that initialize it. But could not find it in .bash_profile (mac) (.bashrc or /etc/environment.conf). I will update the answer if the location is found

+5
source

Source: https://habr.com/ru/post/1656734/


All Articles