Python 如何在windows 10的cmd shell上在笔记本电脑上本地运行mapreduce程序

Python 如何在windows 10的cmd shell上在笔记本电脑上本地运行mapreduce程序,python,hadoop,mapreduce,hadoop-streaming,Python,Hadoop,Mapreduce,Hadoop Streaming,我正在尝试在笔记本电脑上运行本地MapReduce程序,并安装hadoop 2.8版本。我不知道如何在cmdshell中使用下面的命令 这是我的命令,还共享映射器和reducer代码。和我的CSV文件中的数据 D:\hadoop\bin\hadoop jar D:\hadoop\share\hadoop\tools\lib\hadoop-streaming-2.3.0.jar -D mapred.reduce.tasks=0 -file /reducer.py -mapper "mapper.

我正在尝试在笔记本电脑上运行本地MapReduce程序,并安装hadoop 2.8版本。我不知道如何在cmdshell中使用下面的命令

这是我的命令,还共享映射器和reducer代码。和我的CSV文件中的数据

D:\hadoop\bin\hadoop jar D:\hadoop\share\hadoop\tools\lib\hadoop-streaming-2.3.0.jar 
-D mapred.reduce.tasks=0
-file /reducer.py -mapper "mapper.py" 
-input /data2.csv -input /data2.csv 
-output /output

该命令在任何Hadoop环境中都应该是一样的

FWIW,您可能至少应该切换到使用Pyspark

#!/usr/bin/python3
#mapper.py
import sys

# input comes from STDIN (standard input)
for line in sys.stdin:
    line = line.strip()
    line = line.split(",")

    if len(line) >=2:
        sex = line[1]
        age = line[2]
        print ('%s\t%s' % (sex, age))
#!/usr/bin/python3
#Reducer.py
import sys

sex_age = {}

#Partitoner
for line in sys.stdin:
    line = line.strip()
    sex, age = line.split('\t')

    if sex in sex_age:
        sex_age[sex].append(int(age))
    else:
        sex_age[sex] = []
        sex_age[sex].append(int(age))

#Reducer
for sex in sex_age.keys():
    ave_age = sum(sex_age[sex])*1.0 / len(sex_age[sex])
    print ('%s\t%s'% (sex, ave_age))