错误:java.lang.RuntimeException:PipeMapRed.waitOutputThreads:子进程在AWS-EMR上失败,代码为1,但在本地计算机上工作

问题描述

我正在尝试运行一个简单的mapreduce代码,以使用mapper.py进行读取,获取mapper.py的输出,并通过reducer.py进行读取。此代码在本地计算机上有效,但是当我在aws-emr上尝试时,出现以下错误-

Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess Failed with code 1

这是input.txt,mapper.py和reducer.py

input.txt

scott,haris
jenifer,smith
ted,brandy
amanda,woods
bob,wilton
damn,halloween

mapper.py

#!/usr/bin/env python

import sys

for line in sys.stdin:
    x = line.strip()
    first,last = x.split(",")
    print '%s\t%s' % (first,last)

reducer.py

#!/usr/bin/env python
import sys

for line in sys.stdin:
    x = line.strip()
    key,value = x.split('\t')
    print '%s\t%s' % (key,value)

我正在使用以下命令:

hadoop jar /usr/lib/hadoop/hadoop-streaming.jar -files s3://test/mapper.py,s3://test/reducer.py -mapper "python mapper.py" -reducer "python reducer.py" -input s3://test/input.txt -output s3://test/output

解决方法

您似乎在使用python reducer / mapper脚本时遇到问题,能否检查以下两件事

1。您的MapperReducer脚本是否可执行(确保您使用指向正确的env,例如尝试#!/usr/bin/python )并具有正确的权限?

2。您的Python程序是正确的,例如,如果服务器运行的是python3,则需要在print()或脚本的其他任何问题中使用方括号。

尝试使用bash在emr中正常执行python,并查看其是否有效