gpt4 book ai didi

apache-spark - PySpark 错误 : Input path does not exist

转载 作者:行者123 更新时间:2023-12-01 13:39:29 25 4
gpt4 key购买 nike

我正在尝试使用 PySpark 执行数据转换。

我有一个包含数据的文本文件(CHANGES.txt)

我能够执行命令:

RDDread = sc.textFile("file:///home/test/desktop/CHANGES.txt")

但是当我运行时:RDDread.first()

然后我得到错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/srv/spark/python/pyspark/rdd.py", line 1328, in first
rs = self.take(1)
File "/srv/spark/python/pyspark/rdd.py", line 1280, in take
totalParts = self.getNumPartitions()
File "/srv/spark/python/pyspark/rdd.py", line 356, in getNumPartitions
return self._jrdd.partitions().size()
File "/srv/spark/python/lib/py4j-0.10.3-src.zip/py4j/java_gateway.py", line 1133, in __call__
File "/srv/spark/python/pyspark/sql/utils.py", line 63, in deco
return f(*a, **kw)
File "/srv/spark/python/lib/py4j-0.10.3-src.zip/py4j/protocol.py", line 319, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o256.partitions.
: org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/home/test/desktop/CHANGES.txt
at org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:287)
at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:229)
at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:315)
at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:199)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:248)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:246)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:246)
at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:248)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:246)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:246)
at org.apache.spark.api.java.JavaRDDLike$class.partitions(JavaRDDLike.scala:60)
at org.apache.spark.api.java.AbstractJavaRDDLike.partitions(JavaRDDLike.scala:45)
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)

似乎是提到文件路径不存在。我该如何解决这个问题。我的 linux 机器上安装了 python、Java 和 spark。

最佳答案

如果您在集群模式下运行,则需要在同一共享文件系统的所有节点之间复制文件。然后 spark 读取该文件,否则你应该使用 HDFS

我将 txt 文件复制到 HDFS,spark 从 HDFS 获取文件。

我在所有节点的共享文件系统上复制了 txt 文件,然后 spark 读取该文件。

两者都对我有用

关于apache-spark - PySpark 错误 : Input path does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41455415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com