AWS Lambda /tmp python script import module error

Solution 1:

Executing another python process does not copy Lambda's PYTHONPATH by default:

os.system('python ' + local_file_name)

Rewrite like this:

os.system('PYTHONPATH=/var/runtime python ' + local_file_name)

In order to find out complete PYTHONPATH the current Lambda version is using, add the following to the first script (one executed by Lambda):

import sys
print(sys.path)