Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么pySpark只能运行udf函数?_Python_Apache Spark_Pyspark_Apache Spark Sql_User Defined Functions - Fatal编程技术网

Python 为什么pySpark只能运行udf函数?

Python 为什么pySpark只能运行udf函数?,python,apache-spark,pyspark,apache-spark-sql,user-defined-functions,Python,Apache Spark,Pyspark,Apache Spark Sql,User Defined Functions,我已经在一台EC2机器上设置了pyspark,它有两个节点。我正在用这个命令运行pyspark pyspark --master spark://10.0.1.13:7077 --driver-memory 5G --executor-memory 12G --total-executor-cores 10 我的python脚本仅在运行UDF函数时失败。我无法调试为什么只使用udf而不使用脚本的任何其他部分,或者为什么不使用完整脚本 路径: (base) [ec2-user@ip-10-0-

我已经在一台EC2机器上设置了pyspark,它有两个节点。我正在用这个命令运行pyspark

 pyspark --master spark://10.0.1.13:7077 --driver-memory 5G --executor-memory 12G --total-executor-cores 10
我的python脚本仅在运行UDF函数时失败。我无法调试为什么只使用udf而不使用脚本的任何其他部分,或者为什么不使用完整脚本

路径:

(base) [ec2-user@ip-10-0-1-13 ~]$ which pyspark
~/anaconda2/bin/pyspark
(base) [ec2-user@ip-10-0-1-13 ~]$ which python
~/anaconda2/bin/python
Python脚本:

def getDateObjectYear(dateString):
    dateString=dateString.strip()
    return dateString

dateObjectUDFYear = udf(getDateObjectYear)

checkin_date_yelp_df=checkin_date_yelp_df.withColumn('year', dateObjectUDFYear(checkin_date_yelp_df.date))
运行
checkin\u date\u yelp\u df.show(5)
“我收到这个错误

Py4JJavaError: An error occurred while calling o98.showString.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 14.0 failed 4 times, most recent failure: Lost task 0.3 in stage 14.0 (TID 230, 10.0.1.13, executor 0): java.io.IOException: Cannot run program "~/anaconda2/bin/python": error=2, No such file or directory
..
..
..
..
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Py4JJavaError:调用o98.showString时出错。
:org.apache.spark.sparkeexception:作业因阶段失败而中止:阶段14.0中的任务0失败4次,最近的失败:阶段14.0中的任务0.3丢失(TID 230,10.0.1.13,执行器0):java.io.IOException:无法运行程序“~/anaconda2/bin/python”:错误=2,没有这样的文件或目录
..
..
..
..
原因:java.io.IOException:error=2,没有这样的文件或目录
位于java.lang.UNIXProcess.forkAndExec(本机方法)
位于java.lang.UNIXProcess(UNIXProcess.java:247)
在java.lang.ProcessImpl.start(ProcessImpl.java:134)处
位于java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

结果是我在
中错误地配置了2条路径。bashrc

正确的方法:

export PYTHONPATH=/home/ec2-user/anaconda/bin/python
export PYSPARK_PYTHON=/home/ec2-user/anaconda/bin/python

您能否在本地[*]模式下运行此代码并检查问题是否仍然存在。是的,刚刚尝试过。同样的错误