【发布时间】:2013-02-27 09:02:17
【问题描述】:
我正在尝试使用 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”它可以工作,但该软件包不可用,我还尝试将 #!/usr/bin/env python 添加到我的 python 脚本顶部和它也没有工作
【问题讨论】:
-
看起来你有一个以这一行开头的可执行 python 脚本:
#!/usr/bin/env python2.5。在这种情况下,应该有一个名为 python2.5 的二进制文件被调用来运行脚本。你的机器上是否存在那个版本的python?在命令行运行/usr/bin/env python2.5看看。 -
@hughdbrown 我的机器上没有那个版本,python 脚本之一 (mapper.py) 以这一行开头:#!/usr/bin/env python2.5 所以我只是改变了它以这一行开头:#!/usr/bin/env python 并且它起作用了。谢谢
-
#!/usr/bin/env python在PATH中查找python。当您的文件系统上有/usr/bin/python时它不起作用意味着/usr/bin/不在您启动程序的执行上下文中的 PATH 中。