Issue375

Title Compiling Python scripts with Nuitka on AWS Lambda crashes
Priority bug Status resolved
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.

Messages
msg2238 (view) Author: kayhayen Date: 2017-10-17.11:48:18
I just made the stable release that ought to fix this. Please re-open if this is 
not solved. But it ought to be good now.
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:

http://nuitka.net/doc/factory.html

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

Thanks,
Kay
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 test.py`

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
```sh
# 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!")' > test.py
docker cp test.py lambda:/var/task

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

# But using Nuitka will error.
docker exec lambda nuitka-run test.py
```
History
Date User Action Args
2017-10-17 11:48:18kayhayensetstatus: in-progress -> resolved
messages: + msg2238
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