hadoop /usr/bin/env: python: 没有那个文件或目录
我正在尝试通过一个shell脚本运行一个hadoop流式服务器,使用的命令是:
hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-0.19.2-streaming.jar -input $1 -output Twitter/Net.pegasus -mapper 'mapper.py Reverse' -reducer NONE -file mapper.py
hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-0.19.2-streaming.jar -input $1 -output Twitter/Net.exclude -mapper 'mapper.py Reverse' -reducer reducer.py -file mapper.py -file reducer.py -file ../twitter/exclude.txt
hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-0.19.2-streaming.jar -input $1 -output Twitter/Net.complete -mapper 'mapper.py Reverse' -reducer reducer.py -file mapper.py -file reducer.py
但是我遇到了以下错误:
/usr/bin/env: python2.5: No such file or directory
java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 127
at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:362)
at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:576)
at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:135)
at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:57)
at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:36)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:436)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1136)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
不过,我已经安装了更高版本的python。
$ which python
/usr/bin/python
$ python --version
Python 2.7.3
我在其他帖子上看到说通过“apt-get install python2.5”可以解决这个问题,但那个软件包并不可用。我还尝试在我的python脚本顶部添加了#!/usr/bin/env python,但也没有用。
1 个回答
0
$ which python
/usr/bin/python
$ python --version
Python 2.7.3
说明你安装的Python版本比默认版本要高。你需要确保集群中的每个节点都是这样。举个例子,我在一个Redhat 6.4版本的集群上工作,默认的Python版本是2.6,但我对主节点做了一些自定义,所以它和数据节点的版本不一样。
因此,你需要配置你的映射器,让它调用每个节点上都存在的Python。
在Python脚本的开头加上
#!/usr/bin/python
对我来说总是有效。