最近在学习研究pyspark机器学习算法,执行代码出现如下异常:
19/06/29 10:08:26 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:379)
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:394)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:387)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80)
...........
19/06/29 10:08:26 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.
at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:379)
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:394)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:387)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80)
...........
19/06/29 10:08:26 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
从程序运行度方面来讲,这个异常并不影响spark程序的继续执行。可是做为一个程序员看到异常就如出现bug,必须让这种异常消失!
分析异常:根据提示应该是Hadoop binaries.中缺乏winutils.exe这个配置。
解决方法:
1.首先检查本地window环境是否已经安装hadoop,若没有则先配置hadoop环境变量
1)下载Hadoop,我本次操做使用的是hadoop-2.7.3,固然你能够根据本身需求去官网下载
官网下载地址:
网盘分享我使用的版本:
连接: https://pan.baidu.com/s/1-ssNBynSzrC5iG5ozwqAUA 提取码: zdu5
2)配置windows环境变量。本机是windows10系统
先添加HADOOP_HOME配置

在配置path路径:html
3) 下载winutils.exe,hadoop.dll放到hadoop环境的bin目录,建议尽可能使用版本匹配的,必然hadoop-2.6就使用2.6版本的。2.7版本就使用2.7.。理论上2.7版本能够使用在2.6版本上java
这里提供hadoop-2.7.3版本的这2个文件:连接: https://pan.baidu.com/s/1r5rZWqU2O7wu2WtAhmt1KA 提取码: pxr9程序员

4)重启电脑再次测试 异常提示消失算法
提醒:这个异常提示并不必定是spark程序开发时才会出现。在作hadoop程序开发必然写mapreduce程序时 也会遇到一样状况。操做方法一致便可。apache
原文出处:https://www.cnblogs.com/mdlcw/p/11106218.htmlwindows