Spark installation - Error: Could not find or load main class org.apache.spark.launcher.Main

二次信任 提交于 2020-08-07 20:15:45

问题


After spark installation 2.3 and setting the following env variables in .bashrc (using gitbash)

  1. HADOOP_HOME

  2. SPARK_HOME

  3. PYSPARK_PYTHON

  4. JDK_HOME

executing $SPARK_HOME/bin/spark-submit is displaying the following error.

Error: Could not find or load main class org.apache.spark.launcher.Main

I did some research checking in stackoverflow and other sites, but could not figure out the problem.

Execution environment

  1. Windows 10 Enterprise
  2. Spark version - 2.3
  3. Python version - 3.6.4

Can you please provide some pointers?


回答1:


I had that error message. It probably may have several root causes but this how I investigated and solved the problem (on linux):

  • instead of launching spark-submit, try using bash -x spark-submit to see which line fails.
  • do that process several times ( since spark-submit calls nested scripts ) until you find the underlying process called : in my case something like :

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -cp '/opt/spark-2.2.0-bin-hadoop2.7/conf/:/opt/spark-2.2.0-bin-hadoop2.7/jars/*' -Xmx1g org.apache.spark.deploy.SparkSubmit --class org.apache.spark.repl.Main --name 'Spark shell' spark-shell

So, spark-submit launches a java process and can't find the org.apache.spark.launcher.Main class using the files in /opt/spark-2.2.0-bin-hadoop2.7/jars/* (see the -cp option above). I did an ls in this jars folder and counted 4 files instead of the whole spark distrib (~200 files). It was probably a problem during the installation process. So I reinstalled spark, checked the jar folder and it worked like a charm.

So, you should:

  • check the java command (cp option)
  • check your jars folder ( does it contain ths at least all the spark-*.jar ?)

Hope it helps.




回答2:


I also suffered with the same problem but the solution is we are in lack of some basic file which is need so please delete the Spark folder from your Cdrive and install again



来源:https://stackoverflow.com/questions/50435286/spark-installation-error-could-not-find-or-load-main-class-org-apache-spark-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!