spark on yarn 运行任务提示java.io.IOException: Cannot run program “python3“: error=2, No such file or dire

报错场景:

机器 linux-centos7.6,自带的python 2.7 因为spark对环境的要求所以安装了Anaconda,生成的pyspark环境。但是在执行任务时提示如下报错,网上的方法试了很多,跟我这个不太一样。然后就仔细看了下报错信息,分析一下就是找不到python3执行环境。

然后到/usr/bin/目录下查看了下有没有python3文件,发现果然没有,然后就做了一个软连接跟安装的Anaconda环境中的python进行连接。

具体执行脚本就是:

ln -s /home/anaconda3/envs/pyspark/bin/python3.8  /usr/bin/python3
也就是【ln -s anaconda的python地址  可执行文件】

spark on yarn 运行任务提示java.io.IOException: Cannot run program “python3“: error=2, No such file or dire_第1张图片

报错信息如下:

java.io.IOException: Cannot run program "python3": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at org.apache.spark.api.python.PythonWorkerFactory.startDaemon(PythonWorkerFactory.scala:215)
	at org.apache.spark.api.python.PythonWorkerFactory.createThroughDaemon(PythonWorkerFactory.scala:133)
	at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:106)
	at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:121)
	at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:162)
	at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
	at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:373)
	at org.apache.spark.rdd.RDD.iterator(RDD.scala:337)
	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
	at org.apache.spark.scheduler.Task.run(Task.scala:131)
	at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:506)
	at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1462)
	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:509)
	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)
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.(UNIXProcess.java:247)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 16 more

成功

最后重启spark机器,然后执行任务 成功:

 

你可能感兴趣的:(spark,spark,java,大数据)