从 hdfs 导入文件时 namenode 和 localhost 出错

Error in the namenode, localhost during import of the file from hdfs

我正在使用 python-spark 来解决字数统计问题。我用于导入位于我的 hdfs 中的文本文件的代码行是:

file="hdfs://localhost:50070/user/hduser/input/sample.txt"
input=sc.textFile(file)

当我执行程序时出现以下错误:

py4j.protocol.Py4JJavaError: An error occurred while calling o25.collect. : java.io.IOException: Failed on local exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.; Host Details : local host is: "quickstart.cloudera/127.0.0.1"; destination host is: "localhost":50070;

请帮我铲除它。我卡住了。

尝试 运行 input=sc.textFile(file) 其中 file="/user/hduser/input/sample.txt"

你不需要 hdfs://localhost:50070/