我正在尝试在 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/