2
votes

I am trying to connect to an Oracle db from AWS Lambda using python. I managed to package cx_Oracle but the environment does not find the dependencies.

I had zipped the content, which contained cx_Oracle.so and cx_Oracle-5.2.1-py2.7.egg-info (created on 64bit AWX Linux). I also added the files from instantclient-basic-linux.x64-12.1.0.2.0.zip into local/lib in that zip file.

The error I get is

import cx_Oracle

ImportError: libaio.so.1: cannot open shared object file: No such file or directory

I dynamically change environment variables in python like so:

oracledir = os.path.join(os.getcwd(), 'local', 'lib')
libdir = os.environ['LD_LIBRARY_PATH'] + ":" + os.path.join(os.getcwd(), 'local', 'lib')

command = 'LD_LIBRARY_PATH={} ORACLE_HOME={} python OracleWorker.py "{}"'.format(libdir, oracledir, args)
subprocess.call(command, shell=True)

OracleWorker.py starts with import cx_Oracle

1
Its not worth asking the same question over - please edit your previous question - Frederic Henri
The previous question was regarding a tutorial which was against the policy. The answer you provided was the generic aws tutorial which did not help on this case. The question above details the exact steps I have taken and results I am getting. Please again note that I did follow that tutorial as a first step without results. - Thomas Scott-Kunkel

1 Answers

2
votes

Resolved. Added all dependencies by running ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination Added all those files in destination to lib folder in lambda zip