title: Python Program with sys.stdin gives error - Hadoop Streaming
body: <p>I am trying to learn hadoop streaming. I just wrote a three line python program to check whether everything is working fine but got stuck.</p>
  
  <p>The code :</p>
  
  <pre><code>#!/usr/bin/env python
  
  import sys
  
  for line in sys.stdin:
      print "Inside Loop"
  </code></pre>
  
  <p>The command I used to execute :</p>
  
  <pre><code>hadoop jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.5.1.jar  -file './test.py'  -mapper './test.py' -input ./sample.txt -output ./outfile
  </code></pre>
  
  <p>The error I am getting:</p>
  
  <pre><code>Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 127
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:320)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:533)
          at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
          at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
          at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
          at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:450)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
          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:1614)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
  
  15/01/25 17:09:55 INFO mapreduce.Job: Task Id : attempt_1418762215449_0069_m_000001_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 127
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:320)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:533)
          at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
          at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
          at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
          at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:450)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
          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:1614)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
  </code></pre>
  
  <p>I just want to check whether I can read the file stored in hdfs. I am just using a mapper to check this.</p>
  
  <p>Can someone please tell me what I am doing wrong here?</p>