Can't run binary from within python aws lambda function

前端 未结 6 1946
一生所求
一生所求 2021-01-11 16:57

I am trying to run this tool within a lambda function: https://github.com/nicolas-f/7DTD-leaflet

The tool depends on Pillow which depends on imaging libraries not av

6条回答
  •  余生分开走
    2021-01-11 17:35

    Like the docs mention for Node.js, you need to update the $PATH, else you'll get command not found when trying to run the executables you added at the root of your Lambda package. In Node.js, that's:

    process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']
    

    Now, the same thing in Python:

    import os
    
    # Make the path stored in $LAMBDA_TASK_ROOT available to $PATH, so that we
    # can run the executables we added at the root of our package.
    os.environ["PATH"] += os.pathsep + os.environ['LAMBDA_TASK_ROOT']
    

    Tested OK with Python 3.8.

    (As a bonus, here are some more env variables used by Lambda.)

提交回复
热议问题