Python Mapper on Amazon EMR
Question: 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.


Answer: You just need to add

    
    
       #!/usr/bin/env python 
    

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

