【发布时间】:2013-09-27 18:33:52
【问题描述】:
我正在尝试在 Hadoop 上运行 Python 程序。该程序涉及 NLTK 库。该程序还利用了 Hadoop Streaming API,如 here 所述。
mapper.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')
是未注释,然后程序失败并说
作业不成功。错误:超出允许的失败地图任务数 限制。失败次数:1。
我已经检查并在一个独立的 python 程序中,
打印 stopwords.words('english')
工作得非常好,所以我完全不知道为什么它会导致我的 Hadoop 程序失败。
我将不胜感激任何帮助!谢谢
【问题讨论】:
-
您的 hadoop 目录中没有 ntlk 语料库。试试这个stackoverflow.com/questions/10716302/…
-
@user1525721 感谢您的回复。会试一试并回帖。如果我在所有节点上都有 NLTK,这仍然是必要的吗?
-
您提供映射器 n 减速器的路径。同样,您必须指出您的 python 库才能使用它。
-
@user1525721 感谢您的澄清。另一个问题——
from nltk.corpus import stopwords怎么不会导致它失败?
标签: python hadoop mapreduce cluster-analysis