[英]Python Mapper on Amazon EMR
I'm trying to run a Python script as a mapper on Amazon EMR. 我正在尝试在Amazon EMR上运行Python脚本作为映射器。
The initial portion of my script resembles: 我的脚本的初始部分类似于:
import sys
import decimal
def some_function(sensor_record):
return 1
That results in the following error output: 这导致以下错误输出:
[...]/mapper_script.py: line 1: import: command not found
[...]/mapper_script.py: line 2: import: command not found
[...]/mapper_script.py: line 5: syntax error near unexpected token `('
[...]/mapper_script.py: line 5: `def some_function(sensor_record):'
Any thoughts on this? 有什么想法吗? I've used EMR successfully before but not with Python. 我以前成功使用过EMR,但没有用过Python。 I get the same result running the job through the web interface and using the boto library. 我通过Web界面和使用boto库获得了相同的结果。
You just need to add 你只需要添加
#!/usr/bin/env python
at the beginning of the script to ensure that EMR picks the right language. 在脚本的开头,以确保EMR选择正确的语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.