Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Mapper on Amazon EMR

I'm trying to run a Python script as a mapper on Amazon EMR.

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. I get the same result running the job through the web interface and using the boto library.

like image 457
bearrito Avatar asked Feb 19 '23 11:02

bearrito


1 Answers

You just need to add

   #!/usr/bin/env python 

at the beginning of the script to ensure that EMR picks the right language.

like image 84
Karthik Kumara Avatar answered Feb 21 '23 00:02

Karthik Kumara