Title Compiling Python scripts with Nuitka on AWS Lambda crashes
Priority bug Status in-progress
Superseder Nosy List carlthome, kayhayen
Assigned To kayhayen Keywords wrong_execution

Created on 2017-08-23.20:27:25 by carlthome, last changed by kayhayen.

msg2217 (view) Author: kayhayen Date: 2017-08-29.17:50:09
Checking the error messages "Could not find" it seems they are only raised when Py_FrozenFlag 
is not set. So Nuitka now sets those now, should resolve that part. This however likely is 
only cosmetic.

I have no idea why no other Python I have come across so far has not had the issue. I do 
suspect that the python binary in /var/lang/bin needs to find the Python shared library in 
"/var/lang/lib/python3.6", which is shown in:

docker exec -i lambda readelf -d /var/lang/bin/python

That says (RPATH)              Library rpath: [/var/lang/lib]

However, I did something like that, for Travis at the time, and therefore the created binary 
says the same. So maybe it will just work. I am too lazy right now to try it out, maybe you 
can try out Nuitka factory:

Using that, things may already work better. Otherwise I will retry one release cycle later 
via PyPI.

msg2214 (view) Author: carlthome Date: 2017-08-23.20:28:50
I'd also like to add that the --standalone mode works fine. E.g.

`docker exec lambda nuitka-run --portable`

runs the script as expected.
msg2213 (view) Author: carlthome Date: 2017-08-23.20:27:23
I'm trying to use Nuitka on AWS Lambda but get errors indicating that something 
Python related is not being linked to properly. AWS Lambda runs Amazon Linux 
which is RHEL based AFAIK.

# Error
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

# Reproduce
# Start an AWS Lambda image in a Docker container.
docker run -itd --name=lambda lambci/lambda:build-python3.6 bash

# And add a simple Python script to the running container.
echo 'print("Hello World!")' >
docker cp lambda:/var/task

# Note that Python is available and working.
docker exec lambda python

# But using Nuitka will error.
docker exec lambda nuitka-run
Date User Action Args
2017-08-29 17:50:10kayhayensetstatus: chatting -> in-progress
assignedto: kayhayen
messages: + msg2217
keyword: + wrong_execution
nosy: + kayhayen
2017-08-23 20:31:47carlthomesettitle: Compiling Python scripts with nuitka on AWS Lambda crashes -> Compiling Python scripts with Nuitka on AWS Lambda crashes
2017-08-23 20:28:50carlthomesetstatus: unread -> chatting
messages: + msg2214
2017-08-23 20:27:25carlthomecreate