python - Hadoop 和 NLTK : Fails with stopwords

标签 python hadoop mapreduce cluster-analysis

我正在尝试在 Hadoop 上运行 Python 程序。该程序涉及到NLTK 库。该程序还利用 Hadoop Streaming API,如所述 here .

映射器.py:

#!/usr/bin/env python
import sys
import nltk
from nltk.corpus import stopwords

#print stopwords.words('english')

for line in sys.stdin:
        print line,

reducer.py:

#!/usr/bin/env python

import sys
for line in sys.stdin:
    print line,

控制台命令:

bin/hadoop jar contrib/streaming/hadoop-streaming.jar \ -file /hadoop/mapper.py -mapper /hadoop/mapper.py -file /hadoop/reducer.py -reducer /hadoop/reducer.py -input /hadoop/input.txt -output /hadoop/output

这运行完美,输出只包含输入文件的行。

但是,当这一行(来自 mapper.py):

#print stopwords.words('english')

未注释,然后程序失败并显示

Job not successful. Error: # of failed Map Tasks exceeded allowed limit. FailedCount: 1.

我已经检查并在一个独立的 python 程序中,

print stopwords.words('english')

工作得很好,所以我完全不明白为什么它会导致我的 Hadoop 程序失败。

如有任何帮助,我将不胜感激!谢谢

最佳答案

'english' 是 print stopwords.words('english') 中的一个文件吗?如果是,您也需要为此使用 -file 以跨节点发送它。

关于python - Hadoop 和 NLTK : Fails with stopwords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19057741/

相关文章:

hadoop - M/R 程序中的几个 map 和 reduce 函数

Hadoop Mapper 运行缓慢

python - 检查属性是否可设置/可删除

hadoop - 我的hadoop配置有什么问题?

hadoop - 谁将有机会先执行,Combiner 还是 Partitioner?

hadoop - Sqoop JDBC 连接在导入之后但在配置单元导入之前超时

hadoop - Mapreduce 配置 : mapreduce. job.split.metainfo.maxsize

Python 两个 For 循环中的两个列表

python - 将python连接到elasticsearch时出现连接错误

python - 在 python 风格中使用正则表达式来匹配字符串中的一个(或全部)bash 波浪号前缀?