我是学习Spark的初学者。我正在看《霍顿·卡劳,安迪·康温斯基,帕特里克·温德尔和马太·扎哈里亚的学习 Spark ”一书。

本书提供了一个python代码示例

>>> lines = sc.textFile("README.md") # Create an RDD called lines
>>> lines.count() # Count the number of items in this RDD
127
>>> lines.first() # First item in this RDD, i.e. first line of README.md
u'# Apache Spark'

我想知道文件“README.md”在哪里?因为书中没有提供任何信息。而且,每当我尝试运行此代码时,都会出现错误
“输入路径不存在:hdfs://quickstart.cloudera:8020 / user / cloudera / README.md”

我在Codera虚拟机上运行此代码以在vmware工作站上运行。

最佳答案

由于我使用cloudera虚拟机进行点火,因此文件README.md在路径“hdfs://quickstart.cloudera:8020 / user / cloudera / README.md”中不存在。现在,我已经使用

lines = sc.textFile("file:///home/cloudera/Desktop/README.md")

Spark将访问本地文件系统中路径“/home/cloudera/Desktop/README.md”中存在的文件。

关于python - 输入路径不存在错误Apache Spark,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41621587/

10-13 09:38