python - Hadoop Hortonwork 沙箱中的 Python 语法错误
问题描述
我正在 Hadoop 上进行字数统计任务,我已经上传了一个映射器和一个减速器代码。(这些 mapper 和 reducer 代码在 Jupyter Notebook 中工作得很好!)
但是,当我在 Hadoop 上运行 reducer 代码时,我收到关于此行的语法错误
Dictionary2 = {word:count for [word,count] in Dictionary1.items() if word.startswith('W')}
这是我的代码:
line 1: cd usr
line 2: cd tmp
line 3: hdfs dfs -get /user/text1.txt
line 4: hdfs dfs -get /user/*.py
line 5: cat text1.txt | python mapper.py | python reducer.py
我得到的错误信息:
Dictionary2 = {word:count for [word,count] in Dictionary1.items() if word.startswith('W')}
(Note: There is an upper arrow pointing under the word 'for')
**Syntax Error: Invalid syntax**
有谁知道是什么原因?这是因为 Jupyter 和 Hadoop 的 Python 版本不同吗?
解决方案
推荐阅读
- c - 字符无法正确比较
- java - 将用户输入字符串转换为类名
- asp.net - 我从 Listview 中获取复选框值一无所获
- .net - CosmsDB 查询日期字段
- ios - 我可以创建一个只能访问特定 IP 的 IOS 应用程序吗?
- python - 按任意间隔对时间索引的 DataFrame 进行分组
- windows-10 - 在 Windows 10 IoT Core 中禁用自动隐藏滚动条
- restfb - RestFB - 如何从收到的用户访问令牌中验证应用程序 ID
- reactjs - undefined 不是对象(评估'_this2.props.navigation')或与其他导航相比结果不一致
- asp.net - PageAsyncTask 与仅调用 await