title: Dataproc Hadoop MapReduce - can't get it to work
body: <p>I'm basically trying to run my first Hadoop MapReduce routine, and I have to use Hadoop and MapReduce, as I am doing this for a class project. I want to use Python for the mapper and reducer as I am most comfortable with this language and it is most familiar to my peers. I felt like the easiest way for me to set this up was through a Google DataProc instance, so I have that running as well. I'll describe what I have done and what resources I have used, but I am relatively new to this and I might be missing something.</p>
  
  <p><strong>Dataproc Configuration</strong></p>
  
  <p><a href="https://i.stack.imgur.com/1HT5w.png" rel="nofollow noreferrer">Dataproc 1</a></p>
  
  <p><a href="https://i.stack.imgur.com/poNu7.png" rel="nofollow noreferrer">Dataproc 2</a></p>
  
  <p><a href="https://i.stack.imgur.com/YG1Sa.png" rel="nofollow noreferrer">Dataproc 3</a></p>
  
  <p>And, then, I'm able to SSH into my primary node. I have the <code>mapper.py</code> and <code>reducer.py</code> files stored in a Google Cloud Storage bucket.</p>
  
  <p>Mapper and reducer code is from <a href="https://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/" rel="nofollow noreferrer">this Micheal Noll blog post</a>, modified to work with Python 3.</p>
  
  <p><strong>mapper.py:</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python
  """mapper.py"""
  
  import sys
  
  # input comes from STDIN (standard input)
  for line in sys.stdin:
      # remove leading and trailing whitespace
      line = line.strip()
      # split the line into words
      words = line.split()
      # increase counters
      # increase counters
      for word in words:
          # write the results to STDOUT (standard output);
          # what we output here will be the input for the
          # Reduce step, i.e. the input for reducer.py
          #
          # tab-delimited; the trivial word count is 1
          #print ('%s\t%s' % (word, 1))
          print(f"{word}\t{1}")
  </code></pre>
  
  <p><strong>reducer.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python
  """reducer.py"""
  
  from operator import itemgetter
  import sys
  
  print_out = lambda x, y: print(f'{x}\t{y}')
  
  current_word = None
  current_count = 0
  word = None
  
  # input comes from STDIN (standard input)
  for line in sys.stdin:
      # remove leading and trailing whitespace
      line = line.strip()
  
      # parse the input we got from mapper.py
      word, count = line.split('\t', 1)
  
      # convert count (currently a string) to int
      try:
          count = int(count)
      except ValueError:
          # count was not a number, so silently
          # ignore/discard this line
          continue
      #print("still working")
  
      # this IF-switch only works because Hadoop sorts map output
      # by key (here: word) before it is passed to the reducer
      if current_word == word:
          current_count += count
      else:
          if current_word:
              # write result to STDOUT
              #print '%s\t%s' % (current_word, current_count)
              print_out(current_word, current_count)
          current_count = count
          current_word = word
  
  # do not forget to output the last word if needed!
  if current_word == word:
      #print '%s\t%s' % (current_word, current_count)
      print_out(current_word, current_count)
  </code></pre>
  
  <p>Finally, I ssh into my master node and then check my python version:</p>
  
  <pre><code>hduser@data-604-m:~$ python
  Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
  [GCC 7.3.0] :: Anaconda, Inc. on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt;
  </code></pre>
  
  <p>And I run the following (adapted from <a href="https://stackoverflow.com/questions/48003377/error-when-running-python-map-reduce-job-using-hadoop-streaming-in-google-cloud">here</a>):</p>
  
  <pre><code>hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming.jar \
      -files gs://data-604-hadoop/mapper.py,gs://data-604-hadoop/reducer.py \
      -mapper mapper.py \
      -reducer reducer.py \
      -input gs://data-604-hadoop/books/pg20417.txt \
      -output gs://data-604-hadoop/output
  </code></pre>
  
  <p>Which results in the following:</p>
  
  <pre><code>hduser@data-604-m:~$ hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming.jar     -files gs://data-604-hadoop/mapper.py,gs://data-604-hadoop/reducer.py     -map
  per mapper.py     -reducer reducer.py     -input gs://data-604-hadoop/books/pg20417.txt     -output gs://data-604-hadoop/output
  packageJobJar: [] [/usr/lib/hadoop-mapreduce/hadoop-streaming-2.9.2.jar] /tmp/streamjob4601880105330541890.jar tmpDir=null
  19/11/12 02:10:46 INFO client.RMProxy: Connecting to ResourceManager at data-604-m/10.162.0.13:8032
  19/11/12 02:10:47 INFO client.AHSProxy: Connecting to Application History server at data-604-m/10.162.0.13:10200
  19/11/12 02:10:47 INFO client.RMProxy: Connecting to ResourceManager at data-604-m/10.162.0.13:8032
  19/11/12 02:10:47 INFO client.AHSProxy: Connecting to Application History server at data-604-m/10.162.0.13:10200
  19/11/12 02:10:49 INFO mapred.FileInputFormat: Total input files to process : 1
  19/11/12 02:10:49 INFO mapreduce.JobSubmitter: number of splits:15
  19/11/12 02:10:49 INFO Configuration.deprecation: yarn.resourcemanager.system-metrics-publisher.enabled is deprecated. Instead, use yarn.system-metrics-publisher
  .enabled
  19/11/12 02:10:49 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1573523684358_0002
  19/11/12 02:10:50 INFO impl.YarnClientImpl: Submitted application application_1573523684358_0002
  19/11/12 02:10:50 INFO mapreduce.Job: The url to track the job: http://data-604-m:8088/proxy/application_1573523684358_0002/
  19/11/12 02:10:50 INFO mapreduce.Job: Running job: job_1573523684358_0002
  19/11/12 02:10:58 INFO mapreduce.Job: Job job_1573523684358_0002 running in uber mode : false
  19/11/12 02:10:58 INFO mapreduce.Job:  map 0% reduce 0%
  19/11/12 02:11:10 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000000_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:10 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000001_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:12 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000002_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:12 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000004_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:12 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000003_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:19 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000000_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:20 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000001_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:24 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000005_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:24 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000006_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  
  19/11/12 02:11:24 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000007_0, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:28 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000002_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:30 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000004_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:37 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000001_2, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:38 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000000_2, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:38 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000003_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:39 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000005_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:40 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000006_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:48 INFO mapreduce.Job: Task Id : attempt_1573523684358_0002_m_000007_1, Status : FAILED
  Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 1
          at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
          at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
          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:458)
          at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
          at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
          at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)
  19/11/12 02:11:49 INFO mapreduce.Job:  map 80% reduce 0%
  19/11/12 02:11:50 INFO mapreduce.Job:  map 100% reduce 100%
  19/11/12 02:11:50 INFO mapreduce.Job: Job job_1573523684358_0002 failed with state FAILED due to: Task failed task_1573523684358_0002_m_000001
  Job failed as tasks failed. failedMaps:1 failedReduces:0
  19/11/12 02:11:50 INFO mapreduce.Job: Counters: 14
          Job Counters 
                  Failed map tasks=19
                  Killed map tasks=14
                  Killed reduce tasks=5
                  Launched map tasks=22
                  Other local map tasks=14
                  Rack-local map tasks=8
                  Total time spent by all maps in occupied slots (ms)=885928
                  Total time spent by all reduces in occupied slots (ms)=0
                  Total time spent by all map tasks (ms)=221482
                  Total vcore-milliseconds taken by all map tasks=221482
                  Total megabyte-milliseconds taken by all map tasks=453595136
          Map-Reduce Framework
                  CPU time spent (ms)=0
                  Physical memory (bytes) snapshot=0
                  Virtual memory (bytes) snapshot=0
  19/11/12 02:11:50 ERROR streaming.StreamJob: Job not successful!
  Streaming Command Failed!
  </code></pre>
  
  <p>And, I honestly have no idea what to do at this point. I have put a lot of time into this and I feel like I'm at a brick wall as I'm not sure what is wrong.</p>
  
  <p>I have also tried:</p>
  
  <pre class="lang-sh prettyprint-override"><code>hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming.jar \
      -files gs://data-604-hadoop/mapper.py,gs://data-604-hadoop/reducer.py \
      -mapper ./mapper.py \
      -reducer ./reducer.py \
      -input gs://data-604-hadoop/books/pg20417.txt \
      -output gs://data-604-hadoop/output
  </code></pre>
  
  <p>With similar results.</p>
  
  <p>I appreciate any help.</p>
  
  <p><strong>Update:</strong>
  I have tried a few more things, without any success.
  I have tried moving my python scripts onto the Hadoop cluster. I then tested them with <code>head -n100 mobydick.txt | ./mapper.py | sort | ./reducer.py</code> and they work. In the comments below I mention that I looked into my shebang and made changes, but they were also unsuccessful.</p>