Can't run binary from within python aws lambda function

前端 未结 6 1738
一生所求
一生所求 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:11

    You may have been misled into what the issue actually is.

    I don't think that the first Popen ran successfully. I think that it just dumped a message in standard error and you're not seeing it. It's probably saying that

    chmod: map_reader: No such file or directory
    

    I suggest you can try either of these 2:

    1. Extract the map_reader from the package into /tmp. Then reference it with /tmp/map_reader.
    2. Do it as recommended by Tim Wagner, General Manager of AWS Lambda who said the following in the article Running Arbitrary Executables in AWS Lambda:

    Including your own executables is easy; just package them in the ZIP file you upload, and then reference them (including the relative path within the ZIP file you created) when you call them from Node.js or from other processes that you’ve previously started. Ensure that you include the following at the start of your function code:

    process.env[‘PATH’] = process.env[‘PATH’] + ‘:’ + process.env[‘LAMBDA_TASK_ROOT’]
    

    The above code is for Node JS but for Python, it's like the following

    import os os.environ['PATH']

    That should make the command command = './map_reader work.

    If they still don't work, you may also consider running chmod 755 map_reader before creating the package and uploading it (as suggested in this other question).

提交回复
热议问题