spark-submit中的错误,但不在pyspark中

时间:2017-01-13 00:21:10

标签: apache-spark pyspark

我有以下配置spark-master节点,spark-worker节点和安装了spark edge 节点。所有节点都具有相同的spark版本( 2.0.2 )。

我试图运行以下代码:

if __name__ == "__main__":
  sc = SparkContext(appName="my_app")
  sqlContext = HiveContext(sc)

  df = sqlContext.read.json(sys.argv[1])

  df.write.parquet(sys.argv[2], mode='overwrite')

  sc.stop()

来自名为hello_world_from_pyspark.py

的pyspark文件

如果我运行相同的代码(执行if ...sc = SparkContext...除外,执行如下:

pyspark

一切都完美无缺,但如果我使用以下代码执行代码:

pyspark --master spark://master:7077

我收到以下错误:

spark-submit --master spark://master:7077 hello_world_from_pyspark.py

知道为什么会这样吗?

更新

在文档之后,我更改了我的代码,因此它使用Traceback (most recent call last): File "/usr/spark-2.0.2/python/lib/pyspark.zip/pyspark/sql/utils.py", line 63, in deco File "/usr/local/lib/python3.4/dist-packages/py4j-0.10.4-py3.4.egg/py4j/protocol.py", line 319, in get_return_value format(target_id, ".", name), value) py4j.protocol.Py4JJavaError: An error occurred while calling o24.conf. : java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveSessionState': at org.apache.spark.sql.SparkSession$.org$apache$spark$sql$SparkSession$$reflect(SparkSession.scala:952) at org.apache.spark.sql.SparkSession.sessionState$lzycompute(SparkSession.scala:111) at org.apache.spark.sql.SparkSession.sessionState(SparkSession.scala:110) at org.apache.spark.sql.SparkSession.conf$lzycompute(SparkSession.scala:133) at org.apache.spark.sql.SparkSession.conf(SparkSession.scala:133) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:237) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:280) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:214) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.apache.spark.sql.hive.HiveSessionState at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.spark.util.Utils$.classForName(Utils.scala:228) at org.apache.spark.sql.SparkSession$.org$apache$spark$sql$SparkSession$$reflect(SparkSession.scala:947) ... 15 more During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/datank/spark-script.py", line 27, in <module> sqlContext = HiveContext(sc) File "/usr/spark-2.0.2/python/lib/pyspark.zip/pyspark/sql/context.py", line 491, in __init__ File "/usr/spark-2.0.2/python/lib/pyspark.zip/pyspark/sql/session.py", line 179, in getOrCreate File "/usr/spark-2.0.2/python/lib/pyspark.zip/pyspark/sql/session.py", line 251, in conf File "/usr/local/lib/python3.4/dist-packages/py4j-0.10.4-py3.4.egg/py4j/java_gateway.py", line 1133, in __call__ answer, self.gateway_client, self.target_id, self.name) File "/usr/spark-2.0.2/python/lib/pyspark.zip/pyspark/sql/utils.py", line 79, in deco pyspark.sql.utils.IllegalArgumentException: "Error while instantiating 'org.apache.spark.sql.hive.HiveSessionState':" ,如下所示:

SparkSession

但错误仍然存​​在,例如它找不到if __name__ == "__main__": sparkSession = SparkSession.builder\ .master("spark://master:7077")\ .appName("hola mundo desde pyspark")\ .enableHiveSupport()\ .getOrCreate() df = sparkSession.read.json(sys.argv[1]) df.show() 。显然这是Java Classpath的问题,但我如何在HiveSessionState

中设置它

0 个答案:

没有答案